struct ArcStr(NonNull<str>);Expand description
An Arc<str>, held as the pointer to its string.
Arc offers no way to reach its data in const context, while a pointer can be dereferenced
there. Holding the pointer that Arc::into_raw returns, instead of the Arc itself, is what
allows CheapStr::as_str to be a const fn.
The unsafe code below relies on this invariant: the pointer is one that Arc::<str>::into_raw
returned, and the ArcStr owns one strong reference to that Arc. From sets it up, taking
over the reference of the Arc it is given, Clone adds a reference for the clone to own and
Drop gives the reference back. Nothing else creates an ArcStr, changes its pointer or
touches the reference counts, and as neither the type nor its field is visible outside of this
file, no other code can.
Tuple Fields§
§0: NonNull<str>Implementations§
Trait Implementations§
impl Send for ArcStr
impl Sync for ArcStr
Auto Trait Implementations§
impl Freeze for ArcStr
impl RefUnwindSafe for ArcStr
impl Unpin for ArcStr
impl UnsafeUnpin for ArcStr
impl UnwindSafe for ArcStr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more