Skip to main content

KpOptionRefCellType

Type Alias KpOptionRefCellType 

Source
pub type KpOptionRefCellType<'a, R, V> = Kp<R, V, &'a R, Ref<'a, V>, &'a mut R, RefMut<'a, V>, for<'b> fn(&'b R) -> Option<Ref<'b, V>>, for<'b> fn(&'b mut R) -> Option<RefMut<'b, V>>>;
Expand description

Keypath for Option<RefCell<T>>: get returns Option<Ref<V>> so the caller holds the guard. Use .get(root).as_ref().map(std::cell::Ref::deref) to get Option<&V> while the Ref is in scope.

Aliased Type§

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

Fields§

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

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

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

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