KP

Enum KP 

Source
pub enum KP<Root> {
    KeyPath(PartialKeyPath<Root>),
    OptionalKeyPath(PartialOptionalKeyPath<Root>),
    WritableKeyPath(PartialWritableKeyPath<Root>),
    WritableOptionalKeyPath(PartialWritableOptionalKeyPath<Root>),
}
Expand description

Enum for basic keypath types (KeyPath, OptionalKeyPath, WritableKeyPath, WritableOptionalKeyPath).

Provides syntactic sugar for functions accepting any basic keypath type.

§Example

fn process_keypath<Root>(kp: KP<Root>) {
    match kp {
        KP::KeyPath(k) => { /* handle KeyPath */ },
        KP::OptionalKeyPath(k) => { /* handle OptionalKeyPath */ },
        KP::WritableKeyPath(k) => { /* handle WritableKeyPath */ },
        KP::WritableOptionalKeyPath(k) => { /* handle WritableOptionalKeyPath */ },
    }
}

Variants§

§

KeyPath(PartialKeyPath<Root>)

A readable keypath that always succeeds.

§

OptionalKeyPath(PartialOptionalKeyPath<Root>)

A readable keypath that may return None.

§

WritableKeyPath(PartialWritableKeyPath<Root>)

A writable keypath that always succeeds.

§

WritableOptionalKeyPath(PartialWritableOptionalKeyPath<Root>)

A writable keypath that may return None.

Implementations§

Source§

impl<Root> KP<Root>

Source

pub fn from_keypath<Value, F>(kp: RustKeyPath<Root, Value, F>) -> Self
where F: for<'r> Fn(&'r Root) -> &'r Value + 'static, Root: 'static, Value: Any + 'static,

Convert from a concrete rust_keypaths::KeyPath.

Source

pub fn from_optional_keypath<Value, F>( kp: RustOptionalKeyPath<Root, Value, F>, ) -> Self
where F: for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, Root: 'static, Value: Any + 'static,

Convert from a concrete rust_keypaths::OptionalKeyPath.

Source

pub fn from_writable_keypath<Value, F>( kp: RustWritableKeyPath<Root, Value, F>, ) -> Self
where F: for<'r> Fn(&'r mut Root) -> &'r mut Value + 'static, Root: 'static, Value: Any + 'static,

Convert from a concrete rust_keypaths::WritableKeyPath.

Source

pub fn from_writable_optional_keypath<Value, F>( kp: RustWritableOptionalKeyPath<Root, Value, F>, ) -> Self
where F: for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static, Root: 'static, Value: Any + 'static,

Convert from a concrete rust_keypaths::WritableOptionalKeyPath.

Trait Implementations§

Source§

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

Source§

fn from(kp: RustKeyPath<Root, Value, F>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(kp: RustOptionalKeyPath<Root, Value, F>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(kp: RustWritableKeyPath<Root, Value, F>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(kp: RustWritableOptionalKeyPath<Root, Value, F>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Root> Freeze for KP<Root>

§

impl<Root> !RefUnwindSafe for KP<Root>

§

impl<Root> !Send for KP<Root>

§

impl<Root> !Sync for KP<Root>

§

impl<Root> Unpin for KP<Root>
where Root: Unpin,

§

impl<Root> !UnwindSafe for KP<Root>

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.