-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Recently I've encountered a problem, when I wanted to return a slice of bytes in an integer:
fn to_bytes(num: &u32) -> &[u8] {
&u32::to_le_bytes(*num)
}
(This is an oversimplification of the original code, which is generic over every integer type along with other stuff)
Obviously, since to_le_bytes(*num)
is dropped when the function returns, this piece of code failed the borrow check. Hence my need for as_le_bytes(num)
, as num
is actually alive all this time!
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.