Skip to main content

KpType

Struct KpType 

Source
pub struct KpType<R, V, G, S>
where G: for<'r> Fn(&'r R) -> Option<&'r V>, S: for<'r> Fn(&'r mut R) -> Option<&'r mut V>,
{ /* private fields */ }

Implementations§

Source§

impl<T> KpType<Arc<Mutex<T>>, Arc<Mutex<T>>, for<'r> fn(&'r Arc<Mutex<T>>) -> Option<&'r Arc<Mutex<T>>>, for<'r> fn(&'r mut Arc<Mutex<T>>) -> Option<&'r mut Arc<Mutex<T>>>>

Source

pub fn identity_arc_mutex() -> Self

Source§

impl<R, V, G, S> KpType<R, V, G, S>
where G: for<'r> Fn(&'r R) -> Option<&'r V>, S: for<'r> Fn(&'r mut R) -> Option<&'r mut V>,

Source

pub fn new(get: G, set: S) -> Self

Source

pub fn get<'a>(&self, r: &'a R) -> Option<&'a V>

Source

pub fn get_mut<'a>(&self, r: &'a mut R) -> Option<&'a mut V>

Source

pub fn then<SubValue, G2, S2>( self, next: KpType<V, SubValue, G2, S2>, ) -> KpType<R, SubValue, impl for<'r> Fn(&'r R) -> Option<&'r SubValue>, impl for<'r> Fn(&'r mut R) -> Option<&'r mut SubValue>>
where G2: for<'r> Fn(&'r V) -> Option<&'r SubValue>, S2: for<'r> Fn(&'r mut V) -> Option<&'r mut SubValue>, V: 'static,

Source§

impl<R> KpType<R, R, for<'r> fn(&'r R) -> Option<&'r R>, for<'r> fn(&'r mut R) -> Option<&'r mut R>>

Source

pub fn identity() -> Self

Creates an identity keypath that returns the value itself

Source§

impl<R, V, G, S> KpType<R, V, G, S>
where G: for<'r> Fn(&'r R) -> Option<&'r V>, S: for<'r> Fn(&'r mut R) -> Option<&'r mut V>,

Source

pub fn for_arc( self, ) -> KpType<Arc<R>, V, impl for<'r> Fn(&'r Arc<R>) -> Option<&'r V>, impl for<'r> Fn(&'r mut Arc<R>) -> Option<&'r mut V>>

Source

pub fn for_rc( self, ) -> KpType<Rc<R>, V, impl for<'r> Fn(&'r Rc<R>) -> Option<&'r V>, impl for<'r> Fn(&'r mut Rc<R>) -> Option<&'r mut V>>

Trait Implementations§

Source§

impl<R: Debug, V: Debug, G, S> Debug for KpType<R, V, G, S>
where G: for<'r> Fn(&'r R) -> Option<&'r V> + Debug, S: for<'r> Fn(&'r mut R) -> Option<&'r mut V> + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R, V, G, S> Freeze for KpType<R, V, G, S>
where G: Freeze, S: Freeze,

§

impl<R, V, G, S> RefUnwindSafe for KpType<R, V, G, S>

§

impl<R, V, G, S> Send for KpType<R, V, G, S>
where G: Send, S: Send, R: Send, V: Send,

§

impl<R, V, G, S> Sync for KpType<R, V, G, S>
where G: Sync, S: Sync, R: Sync, V: Sync,

§

impl<R, V, G, S> Unpin for KpType<R, V, G, S>
where G: Unpin, S: Unpin, R: Unpin, V: Unpin,

§

impl<R, V, G, S> UnsafeUnpin for KpType<R, V, G, S>
where G: UnsafeUnpin, S: UnsafeUnpin,

§

impl<R, V, G, S> UnwindSafe for KpType<R, V, G, S>

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> 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, 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.