Skip to main content

Dep

Struct Dep 

Source
pub struct Dep<Head, Tail>(pub Head, pub Tail);
Expand description

Static dependency container (Heterogeneous List).

This structure allows storing mixed types of dependencies and accessing them in a zero-cost manner (offsets calculated at compile time).

Tuple Fields§

§0: Head§1: Tail

Implementations§

Source§

impl Dep<(), ()>

Source

pub fn new() -> Self

Source§

impl<Head, Tail> Dep<Head, Tail>

Source

pub fn add<T>(self, item: T) -> Dep<T, Self>

Prepend a new dependency to the list.

Source

pub fn get<T, I>(&self) -> &T
where Self: Has<T, I>,

Access a dependency by type.

The index I is automatically inferred by the compiler. This method shadows the trait method to provide better type inference.

Source

pub fn get_mut<T, I>(&mut self) -> &mut T
where Self: Has<T, I>,

access a mutable dependency by type.

Trait Implementations§

Source§

impl<Head: Clone, Tail: Clone> Clone for Dep<Head, Tail>

Source§

fn clone(&self) -> Dep<Head, Tail>

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<Head: Debug, Tail: Debug> Debug for Dep<Head, Tail>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Head: Default, Tail: Default> Default for Dep<Head, Tail>

Source§

fn default() -> Dep<Head, Tail>

Returns the “default value” for a type. Read more
Source§

impl<T, Tail> Has<T, Here> for Dep<T, Tail>

Base case: The item matches the Head.

Source§

fn get(&self) -> &T

Source§

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

Source§

impl<Head, Tail, T, Index> Has<T, There<Index>> for Dep<Head, Tail>
where Tail: Has<T, Index>,

Recursive case: The item is not in Head, look into Tail.

Source§

fn get(&self) -> &T

Source§

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

Source§

impl<Head: Copy, Tail: Copy> Copy for Dep<Head, Tail>

Auto Trait Implementations§

§

impl<Head, Tail> Freeze for Dep<Head, Tail>
where Head: Freeze, Tail: Freeze,

§

impl<Head, Tail> RefUnwindSafe for Dep<Head, Tail>
where Head: RefUnwindSafe, Tail: RefUnwindSafe,

§

impl<Head, Tail> Send for Dep<Head, Tail>
where Head: Send, Tail: Send,

§

impl<Head, Tail> Sync for Dep<Head, Tail>
where Head: Sync, Tail: Sync,

§

impl<Head, Tail> Unpin for Dep<Head, Tail>
where Head: Unpin, Tail: Unpin,

§

impl<Head, Tail> UnwindSafe for Dep<Head, Tail>
where Head: UnwindSafe, Tail: 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.