WritableKeyPath

Struct WritableKeyPath 

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

Implementations§

Source§

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

Source

pub fn new(getter: F) -> Self

Source

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

Source

pub fn for_result<E>( self, ) -> WritableOptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r mut Result<Root, E>) -> Option<&'r mut Value> + 'static>
where F: 'static, Root: 'static, Value: 'static, E: 'static,

Adapt this keypath to work with Result<Root, E> instead of Root This unwraps the Result and applies the keypath to the Ok value

Source

pub fn for_box_root( self, ) -> WritableKeyPath<Box<Root>, Value, impl for<'r> Fn(&'r mut Box<Root>) -> &'r mut Value + 'static>
where Value: Sized + 'static, F: 'static, Root: 'static,

Source

pub fn for_option( self, ) -> WritableOptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r mut Option<Root>) -> Option<&'r mut Value> + 'static>
where F: 'static, Root: 'static, Value: 'static,

Adapt this keypath to work with Option instead of Root This unwraps the Option and applies the keypath to the Some value

Source

pub fn to_optional( self, ) -> WritableOptionalKeyPath<Root, Value, impl for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static>
where F: 'static,

Convert a WritableKeyPath to WritableOptionalKeyPath for chaining This allows non-optional writable keypaths to be chained with then()

Source

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

Source

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

Source

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

Source

pub fn with_box_mut<Callback, R>(&self, boxed: &mut Box<Root>, f: Callback) -> R
where F: Clone, Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Box

Source

pub fn with_result_mut<Callback, R, E>( &self, result: &mut Result<Root, E>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Result

Source

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

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

Source

pub fn with_refcell_mut<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a RefCell

Source

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

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

Source

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

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

Source

pub fn iter_mut<'r, T>(&self, root: &'r mut Root) -> Option<IterMut<'r, T>>
where Value: AsMut<[T]> + 'r,

Get a mutable iterator over a Vec when Value is Vec Returns Some(iterator) if the value is a Vec, None otherwise

Source

pub fn extract_mut_from_slice<'r>( &self, slice: &'r mut [Root], ) -> Vec<&'r mut Value>

Extract mutable values from a slice of owned mutable values Returns a Vec of mutable references to the extracted values

Source

pub fn extract_mut_from_ref_slice<'r>( &self, slice: &'r mut [&'r mut Root], ) -> Vec<&'r mut Value>

Extract mutable values from a slice of mutable references Returns a Vec of mutable references to the extracted values

Source

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

Chain this keypath with another writable keypath Returns a WritableKeyPath that chains both keypaths

Source

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

Chain this keypath with a writable optional keypath Returns a WritableOptionalKeyPath that chains both keypaths

Source

pub fn to_arc_rwlock_kp<InnerValue>(self) -> Self
where Value: Borrow<Arc<RwLock<InnerValue>>>,

Convert this writable keypath to an Arc chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

Source

pub fn to_arc_mutex_kp<InnerValue>(self) -> Self
where Value: Borrow<Arc<Mutex<InnerValue>>>,

Convert this writable keypath to an Arc chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

Source§

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

Source

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

Convert to PartialWritableKeyPath (hides Value type)

Source

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

Alias for to_partial() - converts to PartialWritableKeyPath

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> WritableKeyPath<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
Source§

impl<Root, Value, F> Debug for WritableKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r mut Root) -> &'r mut Value,

Source§

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

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

impl<Root, Value, F> Display for WritableKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r mut Root) -> &'r mut Value,

Source§

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

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

impl<Root, Value, F> WithContainer<Root, Value> for WritableKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r mut Root) -> &'r mut Value,

Source§

fn with_arc<Callback, R>(&self, _arc: &Arc<Root>, _f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc
Source§

fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Box
Source§

fn with_box_mut<Callback, R>(&self, boxed: &mut Box<Root>, f: Callback) -> R
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Box
Source§

fn with_rc<Callback, R>(&self, _rc: &Rc<Root>, _f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Rc
Source§

fn with_result<Callback, R, E>( &self, _result: &Result<Root, E>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Result
Source§

fn with_result_mut<Callback, R, E>( &self, result: &mut Result<Root, E>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Result
Source§

fn with_option<Callback, R>( &self, _option: &Option<Root>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

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

fn with_option_mut<Callback, R>( &self, option: &mut Option<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an Option
Source§

fn with_refcell<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a RefCell
Source§

fn with_refcell_mut<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a RefCell
Source§

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

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

fn with_mutex_mut<Callback, R>( &self, mutex: &mut Mutex<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Mutex
Source§

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

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

fn with_rwlock_mut<Callback, R>( &self, rwlock: &mut RwLock<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an RwLock
Source§

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

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

fn with_arc_rwlock_mut<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<Root, Value, F> UnwindSafe for WritableKeyPath<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.