-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use raw pointer casts for slice, str's .as_ptr() #31999
Conversation
We can now use raw pointer casts `*const [T] as *const T` and `*const str as *const u8` instead of .repr() for getting the pointer out of a slice.
(rust_highfive has picked a reviewer for you, use r? to override) |
This should be a good idea, using simpler code should improve compile time (however slightly). We don't have to call It looks like it generates exactly the same code in the end. https://gist.github.com/bluss/085ae73a253b9cc82788 ndarray's benchmarks stay the same, so it didn't seem to affect any slice loop optimizations that I could see. |
This is great IMO! @bors r+ |
📌 Commit 63c4065 has been approved by |
Use raw pointer casts for slice, str's .as_ptr() We can now use raw pointer casts `*const [T] as *const T` and `*const str as *const u8` instead of .repr() for getting the pointer out of a slice.
I understand from context (and by assuming this code is correct) what |
It is documented in this RFC https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md#casts Also discussed in rust-lang/rfcs/pull/1052 |
Use raw pointer casts for slice, str's .as_ptr()
We can now use raw pointer casts
*const [T] as *const T
and*const str as *const u8
instead of .repr() for getting thepointer out of a slice.