pub struct Ref<'id, T: Flat> { /* private fields */ }Expand description
Typed position branded to a Session. Copy, no borrow.
Ref<'id, T> carries only a byte position (4 bytes) and a phantom brand —
it borrows nothing, so multiple Refs can coexist with &mut Session without
borrow conflicts.
§Soundness
The 'id lifetime is invariant (via Brand’s
fn(&'id ()) -> &'id () phantom). Combined with the for<'id> bound on
Region::session, this gives two compile-time
guarantees:
- No escape: A
Ref<'id, T>cannot be returned from the session closure because'idis universally quantified and cannot unify with any external lifetime. - No cross-session use: A
Reffrom session A cannot be passed to session B because their'idbrands are distinct.
Both properties are verified by compile-fail tests.
Trait Implementations§
impl<T: Flat> Copy for Ref<'_, T>
impl<T: Flat> Eq for Ref<'_, T>
Auto Trait Implementations§
impl<'id, T> Freeze for Ref<'id, T>
impl<'id, T> RefUnwindSafe for Ref<'id, T>where
T: RefUnwindSafe,
impl<'id, T> Send for Ref<'id, T>where
T: Send,
impl<'id, T> Sync for Ref<'id, T>where
T: Sync,
impl<'id, T> Unpin for Ref<'id, T>where
T: Unpin,
impl<'id, T> UnsafeUnpin for Ref<'id, T>
impl<'id, T> UnwindSafe for Ref<'id, T>where
T: UnwindSafe,
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