738d4a7a36
Allow Weak::as_ptr and friends for unsized T Relaxes `impl<T> Weak<T>` to `impl<T: ?Sized> Weak<T>` for the methods `rc::Weak::as_ptr`, `into_raw`, and `from_raw`. Follow-up to #73845, which did most of the impl work to make these functions work for `T: ?Sized`. We still have to adjust the implementation of `Weak::from_raw` here, however, because I missed a use of `ptr.is_null()` previously. This check was necessary when `into`/`from_raw` were first implemented, as `into_raw` returned `ptr::null()` for dangling weak. However, we now just (wrapping) offset dangling weaks' pointers the same as nondangling weak, so the null check is no longer necessary (or even hit). (I can submit just 17a928f as a separate PR if desired.) As a nice side effect, moves the `fn is_dangling` definition closer to `Weak::new`, which creates the dangling weak. This technically stabilizes that "something like `align_of_val_raw`" is possible to do. However, I believe the part of the functionality required by these methods here -- specifically, getting the alignment of a pointee from a pointer where it may be dangling iff the pointee is `Sized` -- is uncontroversial enough to stabilize these methods without a way to implement them on stable Rust. r? `@RalfJung,` who reviewed #73845. ATTN: This changes (relaxes) the (input) generic bounds on stable fn! |
||
---|---|---|
.. | ||
alloc | ||
collections | ||
prelude | ||
raw_vec | ||
rc | ||
sync | ||
alloc.rs | ||
borrow.rs | ||
boxed.rs | ||
fmt.rs | ||
lib.rs | ||
macros.rs | ||
raw_vec.rs | ||
rc.rs | ||
slice.rs | ||
str.rs | ||
string.rs | ||
sync.rs | ||
task.rs | ||
tests.rs | ||
vec.rs |