Trait keypath::Keyable[][src]

pub trait Keyable: RawKeyable {
    type Mirror;
    fn mirror() -> Self::Mirror;

    fn try_any_at_path(
        &self,
        path: impl AsRef<[PathComponent]>
    ) -> Result<&dyn Any, FieldError> { ... }
fn try_any_at_path_mut(
        &mut self,
        path: impl AsRef<[PathComponent]>
    ) -> Result<&mut dyn Any, FieldError> { ... }
fn item_at_path<T>(&self, path: &KeyPath<Self, T>) -> &T { ... }
fn item_at_path_mut<T>(&mut self, path: &KeyPath<Self, T>) -> &mut T { ... } }
Expand description

A trait for types that can be indexed with keypaths.

Associated Types

A type that describes properties on the inner type, for compile-time checking.

This is the worst part of the code right now? We generate structs with magic names for each Keyable type.

Required methods

Return an instance of this type’s mirror.

Provided methods

Attempt to traverse a series of PathComponents, returning an &dyn Any if successful.

Attempt to traverse a series of PathComponents, returning an &mut dyn Any if successful.

Get a reference to the value at the provided path.

You generally won’t need to call this, since you can use [index] syntax instead.

Assuming the path was constructed with the keypath! macro, this method will not fail.

Panics

I lied, it will fail if you provide an index into a collection and that item does not exist.

Get a mutable reference to the value at the provided path.

You generally won’t need to call this, since you can use [index] syntax instead.

Assuming the path was constructed with the keypath! macro, this method will not fail.

Panics

I lied, it will fail if you provide an index into a collection and that item does not exist.

Implementations on Foreign Types

Implementors