Skip to main content

DynFar

Struct DynFar 

Source
pub struct DynFar<T>
where T: ?Sized,
{ /* private fields */ }
Available on crate feature bank only.
Expand description

A far pointer whose bank is known only at runtime: a group-erased Far.

DynFar is the no-alloc, vtable-free type erasure of Far: the group type becomes a BankNumber stored inline, so far pointers of different banks share one type and can live in the same collection. Every access switches to the stored bank (there is no compile-time group to elide it against).

Obtain one with Far::erase.

§Examples

fn run_each(bank: &mut Bank<GroupZero>, behaviours: &[DynFar<fn(u8)>], state: u8) {
    for b in behaviours {
        b.invoke(bank, (state,));   // switch to each one's bank, run, restore
    }
}

Trait Implementations§

Source§

impl<T> BankSafe for DynFar<T>
where T: ?Sized,

Source§

impl<T> Clone for DynFar<T>
where T: ?Sized,

Source§

fn clone(&self) -> DynFar<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for DynFar<T>
where T: ?Sized,

Source§

impl<F, Args> FarCall<Args> for DynFar<F>
where F: Copy + Fn<Args>, Args: Tuple + BankSafe, <F as FnOnce<Args>>::Output: BankSafe,

Source§

type Output = <F as FnOnce<Args>>::Output

The function’s return type.
Source§

fn invoke<C>( &self, _outer: &mut Bank<C>, args: Args, ) -> <F as FnOnce<Args>>::Output
where C: Group,

Switch into the far function’s bank, call it with args, restore C.
Source§

impl<T> FarWith<T> for DynFar<T>
where T: ?Sized,

Source§

fn there<C, R>( &self, _anchor: Anchor, _outer: &mut Bank<C>, f: impl FnOnce(&T) -> R, ) -> R
where C: Group, R: BankSafe,

Switch into the data’s bank, lend &T to f, restore C. Read more
Source§

impl<T> Sync for DynFar<T>
where T: ?Sized,

Auto Trait Implementations§

§

impl<T> !Send for DynFar<T>

§

impl<T> Freeze for DynFar<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for DynFar<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Unpin for DynFar<T>
where T: ?Sized,

§

impl<T> UnsafeUnpin for DynFar<T>
where T: ?Sized,

§

impl<T> UnwindSafe for DynFar<T>
where T: RefUnwindSafe + ?Sized,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CellValue for T
where T: Copy + BankSafe,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.