Skip to main content

KpType

Type Alias KpType 

Source
pub type KpType<'a, R, V> = Kp<R, V, &'a R, &'a V, &'a mut R, &'a mut V, for<'b> fn(&'b R) -> Option<&'b V>, for<'b> fn(&'b mut R) -> Option<&'b mut V>>;

Aliased Type§

pub struct KpType<'a, R, V> {
    pub get: for<'b> fn(&'b R) -> Option<&'b V>,
    pub set: for<'b> fn(&'b mut R) -> Option<&'b mut V>,
    /* private fields */
}

Fields§

§get: for<'b> fn(&'b R) -> Option<&'b V>

Getter closure: used by Kp::get for read-only access.

§set: for<'b> fn(&'b mut R) -> Option<&'b mut V>

Setter closure: used by Kp::get_mut for mutation.

Implementations§

Source§

impl<'a, R, V> KpType<'a, R, V>
where 'a: 'static,

Source

pub fn to_dynamic(self) -> KpDynamic<R, V>

Converts this keypath (KpType) to KpDynamic for dynamic dispatch and storage. Requires 'a: 'static so the boxed getter/setter closures can be 'static.