OptionalKeyPath

Struct OptionalKeyPath 

Source
pub struct OptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> Option<&'r Value>,
{ /* private fields */ }

Implementations§

Source§

impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> Option<&'r Value>,

Source

pub fn new(getter: F) -> Self

Source

pub fn get<'r>(&self, root: &'r Root) -> Option<&'r Value>

Source

pub fn then<SubValue, G>( self, next: OptionalKeyPath<Value, SubValue, G>, ) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> Option<&'r SubValue>>
where G: for<'r> Fn(&'r Value) -> Option<&'r SubValue> + 'static, F: 'static, Value: 'static,

Source

pub fn for_box<Target>( self, ) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_arc<Target>( self, ) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_rc<Target>( self, ) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_option<T>() -> OptionalKeyPath<Option<T>, T, impl for<'r> Fn(&'r Option<T>) -> Option<&'r T>>

Source

pub fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Option

Source

pub fn with_mutex<Callback, R>( &self, mutex: &Mutex<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Mutex

Source

pub fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an RwLock

Source

pub fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<RwLock>

Source

pub fn with_arc_mutex<Callback, R>( &self, arc_mutex: &Arc<Mutex<Root>>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<Mutex>

Source§

impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, Root: Any + 'static, Value: Any + 'static,

Source

pub fn to_partial(self) -> PartialOptionalKeyPath<Root>

Convert to PartialOptionalKeyPath (hides Value type)

Source

pub fn to_any(self) -> AnyKeyPath

Convert to AnyKeyPath (hides both Root and Value types)

Source

pub fn to(self) -> PartialOptionalKeyPath<Root>

Convert to PartialOptionalKeyPath (alias for to_partial())

Trait Implementations§

Source§

impl<Root: Clone, Value: Clone, F> Clone for OptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> Option<&'r Value> + Clone,

Source§

fn clone(&self) -> OptionalKeyPath<Root, Value, F>

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

Auto Trait Implementations§

§

impl<Root, Value, F> Freeze for OptionalKeyPath<Root, Value, F>
where F: Freeze,

§

impl<Root, Value, F> RefUnwindSafe for OptionalKeyPath<Root, Value, F>
where F: RefUnwindSafe, Root: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Root, Value, F> Send for OptionalKeyPath<Root, Value, F>
where F: Send, Root: Send, Value: Send,

§

impl<Root, Value, F> Sync for OptionalKeyPath<Root, Value, F>
where F: Sync, Root: Sync, Value: Sync,

§

impl<Root, Value, F> Unpin for OptionalKeyPath<Root, Value, F>
where F: Unpin, Root: Unpin, Value: Unpin,

§

impl<Root, Value, F> UnwindSafe for OptionalKeyPath<Root, Value, F>
where F: UnwindSafe, Root: UnwindSafe, Value: 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.