pub struct AnyKeyPath { /* private fields */ }Expand description
AnyKeyPath - Hides both Root and Value types Equivalent to Swift’s AnyKeyPath Useful for storing keypaths in collections without knowing either type
§Why No PhantomData?
Unlike PartialKeyPath, AnyKeyPath doesn’t need PhantomData because:
- Both
RootandValuetypes are completely erased - We store
TypeIdinstead for runtime type checking - The type information is encoded in the closure’s behavior, not the struct
- There’s no generic type parameter to track at compile time
Implementations§
Source§impl AnyKeyPath
impl AnyKeyPath
pub fn new<Root, Value>( keypath: OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>, ) -> Self
Sourcepub fn from<Root, Value>(
keypath: OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>,
) -> Self
pub fn from<Root, Value>( keypath: OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>, ) -> Self
Create an AnyKeyPath from a concrete OptionalKeyPath
Alias for new() for consistency with from() pattern
pub fn get<'r>(&self, root: &'r dyn Any) -> Option<&'r dyn Any>
Sourcepub fn root_type_id(&self) -> TypeId
pub fn root_type_id(&self) -> TypeId
Get the TypeId of the Root type
Sourcepub fn value_type_id(&self) -> TypeId
pub fn value_type_id(&self) -> TypeId
Get the TypeId of the Value type
Trait Implementations§
Source§impl Clone for AnyKeyPath
impl Clone for AnyKeyPath
Source§fn clone(&self) -> AnyKeyPath
fn clone(&self) -> AnyKeyPath
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 moreAuto Trait Implementations§
impl Freeze for AnyKeyPath
impl !RefUnwindSafe for AnyKeyPath
impl !Send for AnyKeyPath
impl !Sync for AnyKeyPath
impl Unpin for AnyKeyPath
impl !UnwindSafe for AnyKeyPath
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