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>
impl<Root> PartialOptionalKeyPath<Root>
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,
pub fn get<'r>(&self, root: &'r Root) -> Option<&'r (dyn Any + 'static)>
Sourcepub fn value_type_id(&self) -> TypeId
pub fn value_type_id(&self) -> TypeId
Get the TypeId of the Value type
Sourcepub fn get_as<'a, Value>(&self, root: &'a Root) -> Option<Option<&'a Value>>where
Value: Any,
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
Sourcepub fn then<MidValue>(
self,
next: PartialOptionalKeyPath<MidValue>,
) -> PartialOptionalKeyPath<Root>where
MidValue: Any + 'static,
Root: 'static,
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,
impl<Root> Clone for PartialOptionalKeyPath<Root>where
Root: Clone,
Source§fn clone(&self) -> PartialOptionalKeyPath<Root>
fn clone(&self) -> PartialOptionalKeyPath<Root>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Root> From<PartialOptionalKeyPath<Root>> for PKP<Root>
impl<Root> From<PartialOptionalKeyPath<Root>> for PKP<Root>
Source§fn from(kp: RustPartialOptionalKeyPath<Root>) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more