-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking Issue for num_as_ne_bytes
feature
#76976
Comments
Ad discussed starting in #64464 (comment) I’m not convinced this feature carries its weight to be included in the standard library, given that |
|
How so? Trying to go beyond "I want to borrow because I want to borrow" |
In a similar vein, I was curious if the opposite existed, converting from let mut a = [1, 2, 3, 4];
let v: &mut u32 = u32::from_ne_bytes_mut(&mut a);
// Then potentially used with
let x = AtomicU32::from_mut(v); I do not have a specific usecase in mind. My thoughts were likewise around avoiding the copy (small as it may be). |
@shepmaster Something kind of like that exists: It returns It's also unsafe because it can transmute to any type. A safe version for integers could be possible, but that won't solve the alignment problem. |
A good point! The original case had a |
Sorry for replying really late here (I accidentally unsubscribed from the issue.) but how should I proceed from here?
Though, the |
This feature would be useful to make this be a safe conversion. Currently this requires unsafe code. We use this type of abstraction in TinyStr; it would also be handy in some serialization-type libraries. |
One other suggestion. It would be useful if this method returned a type like In other words, returning |
Which "this" are you referring to? Why does |
I meant that |
Also: in conjunction with #74985 (comment), this feature would also enable safe conversion from |
Regarding At least, I am not aware of any machinery in |
I think I'm with #76976 (comment) on this one. Given that this can't (portably) have |
@scottmcm Agreed. I think it would be great to wait and see what the Safe Transmute project gives us here. |
The use case is valid but a more general mechanism is direly needed here (something like this came up in Portable SIMD discussions). |
Opened #85679 which removes this feature. |
The feature gate for the issue is
#![feature(num_as_ne_bytes)]
.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
The text was updated successfully, but these errors were encountered: