Skip to main content

Ref

Struct Ref 

Source
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:

  1. No escape: A Ref<'id, T> cannot be returned from the session closure because 'id is universally quantified and cannot unify with any external lifetime.
  2. No cross-session use: A Ref from session A cannot be passed to session B because their 'id brands are distinct.

Both properties are verified by compile-fail tests.

Trait Implementations§

Source§

impl<T: Flat> Clone for Ref<'_, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Flat> Emit<T> for Ref<'_, T>

Source§

fn emit(self, _p: &mut impl Patch) -> Pos

Reserve space for T, write this builder’s data, and return the position.
Source§

unsafe fn write_at(self, p: &mut impl Patch, at: Pos)

Write this builder’s data at position at. Read more
Source§

impl<T: Flat> Hash for Ref<'_, T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Flat> PartialEq for Ref<'_, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Flat> Copy for Ref<'_, T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.