PartialOptionalKeyPath

Struct PartialOptionalKeyPath 

Source
pub struct PartialOptionalKeyPath<Root> { /* private fields */ }
Expand description

PartialOptionalKeyPath - Hides the Value type but keeps Root visible Useful for storing optional keypaths in collections without knowing the exact Value type

§Why PhantomData?

See PartialKeyPath documentation for explanation of why PhantomData is needed.

Implementations§

Source§

impl<Root> PartialOptionalKeyPath<Root>

Source

pub fn new<Value>( keypath: OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>, ) -> PartialOptionalKeyPath<Root>
where Value: Any + 'static, Root: 'static,

Source

pub fn get<'r>(&self, root: &'r Root) -> Option<&'r (dyn Any + 'static)>

Source

pub fn value_type_id(&self) -> TypeId

Get the TypeId of the Value type

Source

pub fn get_as<'a, Value>(&self, root: &'a Root) -> Option<Option<&'a Value>>
where Value: Any,

Try to downcast the result to a specific type

Source

pub fn then<MidValue>( self, next: PartialOptionalKeyPath<MidValue>, ) -> PartialOptionalKeyPath<Root>
where MidValue: Any + 'static, Root: 'static,

Chain with another PartialOptionalKeyPath Note: This requires the Value type of the first keypath to match the Root type of the second For type-erased chaining, consider using AnyKeyPath instead

Trait Implementations§

Source§

impl<Root> Clone for PartialOptionalKeyPath<Root>
where Root: Clone,

Source§

fn clone(&self) -> PartialOptionalKeyPath<Root>

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> From<PartialOptionalKeyPath<Root>> for PKP<Root>

Source§

fn from(kp: RustPartialOptionalKeyPath<Root>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Root> Freeze for PartialOptionalKeyPath<Root>

§

impl<Root> !RefUnwindSafe for PartialOptionalKeyPath<Root>

§

impl<Root> !Send for PartialOptionalKeyPath<Root>

§

impl<Root> !Sync for PartialOptionalKeyPath<Root>

§

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

§

impl<Root> !UnwindSafe for PartialOptionalKeyPath<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> 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.