-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Docs for std::ptr::slice_from_raw_parts #120608
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
Thanks @kornelski for this PR! For reference, here's some discussion: https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 Wouldn't it also be helpful to mention (or even recommend using) To me this was initially not obvious. |
The examples use |
Yes, and I think that's helpful! But it only illustrates the problem, not the solution. |
The solution is going to be domain-specific. In general, there is a distinction between non-existence and emptiness, so treating null as an empty slice is not necessarily the right thing to do. But maybe we can suggest it with that qualification, like "If you are converting from a context where null pointers are used for emptiness, then you may want |
@bors r+ rollup |
Docs for std::ptr::slice_from_raw_parts
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#118623 (Improve std::fs::read_to_string example) - rust-lang#119365 (Add asm goto support to `asm!`) - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts) - rust-lang#121885 (Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type.) - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes) - rust-lang#122099 (Add `#[inline]` to `BTreeMap::new` constructor) - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b) Failed merges: - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#118623 (Improve std::fs::read_to_string example) - rust-lang#119365 (Add asm goto support to `asm!`) - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts) - rust-lang#121832 (Add new Tier-3 target: `loongarch64-unknown-linux-musl`) - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes) - rust-lang#122099 (Add `#[inline]` to `BTreeMap::new` constructor) - rust-lang#122103 (Make TAITs and ATPITs capture late-bound lifetimes in scope) - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b) Failed merges: - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120608 - kornelski:slice-ptr-doc, r=cuviper Docs for std::ptr::slice_from_raw_parts
…=scottmcm DOC: Add FFI example for slice::from_raw_parts() For some discussion, see https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 See also rust-lang#120608.
…=scottmcm DOC: Add FFI example for slice::from_raw_parts() For some discussion, see https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 See also rust-lang#120608.
…=scottmcm DOC: Add FFI example for slice::from_raw_parts() For some discussion, see https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 See also rust-lang#120608.
…=scottmcm DOC: Add FFI example for slice::from_raw_parts() For some discussion, see https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 See also rust-lang#120608.
Rollup merge of rust-lang#123374 - mgeier:doc-slice-from-raw-parts, r=scottmcm DOC: Add FFI example for slice::from_raw_parts() For some discussion, see https://users.rust-lang.org/t/missing-guidance-on-converting-ffi-ptr-length-to-slice/106048 See also rust-lang#120608.
No description provided.