Struct Visitor

Source
pub struct Visitor<Parent, Value> {
    pub parent: Parent,
    pub value: Value,
}
Expand description

A visitor for tree traversal.

Fields§

§parent: Parent

The parent of the visitor.

§value: Value

The value of the visitor.

Implementations§

Source§

impl<Parent, Value> Visitor<Parent, Value>

Source

pub fn new(parent: Parent, value: Value) -> Self

Creates a new visitor.

Trait Implementations§

Source§

impl<Parent: Clone, Value: Clone> Clone for Visitor<Parent, Value>

Source§

fn clone(&self) -> Visitor<Parent, Value>

Returns a copy 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<Parent: Debug, Value: Debug> Debug for Visitor<Parent, Value>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Parent: Default, Value: Default> Default for Visitor<Parent, Value>

Source§

fn default() -> Visitor<Parent, Value>

Returns the “default value” for a type. Read more
Source§

impl<'a, Parent, Value, T> HasBranches<T> for &'a Visitor<Parent, Value>
where Visitor<Parent, Value>: UnsafeClone, T: From<Visitor<Parent, Value>> + 'a, &'a T: HasBranches<T>,

Source§

fn branches_impl(self) -> impl Iterator<Item = T>

This is the method that should be implemented to provide a way to iterate over the branches of a type. It’s discouraged to use this method directly. Instead, use the branches method from the HasBranchesAPIV2 trait.
Source§

impl<Parent, Value> HasParent for Visitor<Parent, Value>
where Self: KnowsVisitor, Parent: Clone + Into<Self::Visitor>,

Source§

fn parent(&self) -> Option<Self::Visitor>

Gets the parent of the object.
Source§

impl<Parent, Value> HasParentMut for Visitor<Parent, Value>
where Self: KnowsVisitor, Self::VisitorMut: UnsafeFrom<Parent>, Parent: Clone,

Source§

unsafe fn parent_mut(&mut self) -> Option<Self::VisitorMut>

Gets the parent of the object.
Source§

impl<Parent, Value> HasPath for Visitor<Parent, Value>
where Value: HasPathSegment, Parent: HasPath,

Source§

fn path(&self) -> Path

Gets the path of the type.
Source§

impl<Parent, Value> HasPathSegment for Visitor<Parent, Value>
where Value: HasPathSegment,

Source§

fn path_segment(&self) -> String

Gets the path segment of the type.
Source§

fn is(&self, identifier: impl PartialEq<String>) -> bool

Checks if the type is identified by the given path segment.
Source§

impl<Parent, Value> HasRoot for Visitor<Parent, Value>
where Self: KnowsVisitor, Parent: HasRoot, Parent::Visitor: Into<Self::Visitor>,

Source§

fn root(&self) -> Self::Visitor

Gets the root of the object.
Source§

impl<Parent, Value> HasRootMut for Visitor<Parent, Value>
where Self: KnowsVisitor, Parent: HasRootMut, Parent::VisitorMut: Into<Self::VisitorMut>,

Source§

unsafe fn root_mut(&mut self) -> Self::VisitorMut

Gets the root of the object.
Source§

impl<Parent, Value> KnowsVisitor for Visitor<Parent, Value>
where Parent: KnowsVisitor,

Source§

type Visitor = <Parent as KnowsVisitor>::Visitor

The visitor type.
Source§

type VisitorMut = <Parent as KnowsVisitor>::VisitorMut

Source§

impl<'a, Parent, Value> UnsafeClone for Visitor<Parent, &'a Value>
where Parent: Clone,

Source§

unsafe fn unsafe_clone(&self) -> Self

Clones the object.
Source§

impl<Parent, Value> UnsafeClone for Visitor<Parent, &mut Value>
where Parent: Clone,

Source§

unsafe fn unsafe_clone(&self) -> Self

Clones the object.

Auto Trait Implementations§

§

impl<Parent, Value> Freeze for Visitor<Parent, Value>
where Parent: Freeze, Value: Freeze,

§

impl<Parent, Value> RefUnwindSafe for Visitor<Parent, Value>
where Parent: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Parent, Value> Send for Visitor<Parent, Value>
where Parent: Send, Value: Send,

§

impl<Parent, Value> Sync for Visitor<Parent, Value>
where Parent: Sync, Value: Sync,

§

impl<Parent, Value> Unpin for Visitor<Parent, Value>
where Parent: Unpin, Value: Unpin,

§

impl<Parent, Value> UnwindSafe for Visitor<Parent, Value>
where Parent: UnwindSafe, Value: UnwindSafe,

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<'a, T> HasBranch<'a> for T

Source§

fn branch<T>(&'a mut self, segment: impl Into<String>) -> &'a mut T
where &'a mut Self: HasGet + HasBranches<&'a mut T>, Self: AddBranch<T> + Sized + HasGetMut<'a>, T: HasPathSegment + 'a, String: Into<T>,

Source§

impl<T> HasBranchesAPI for T

Source§

fn branches_impl2<T>(self) -> impl Iterator<Item = T>
where Self: HasBranches<T> + Sized,

This is used internally. Should use branches instead.
Source§

impl<'a, T> HasBranchesAPIV2<'a> for T

Source§

fn branches<T>(&'a self) -> impl Iterator<Item = T>
where &'a Self: HasBranches<T>, T: 'a,

Iterates over the branches of a type.
Source§

fn branches_mut<T>(&'a mut self) -> impl Iterator<Item = T>
where &'a mut Self: HasBranches<T>, T: 'a,

Iterates over the branches of a type mutably.
Source§

fn all_branches<T>(&'a self) -> impl Iterator<Item = T>
where &'a Self: HasBranches<T>, T: 'a + HasBranches<T> + Copy,

Source§

fn all_branches_mut<T>(&'a mut self) -> impl Iterator<Item = T>
where &'a mut Self: HasBranches<T>, T: 'a + HasBranches<T> + Copy,

Source§

impl<T> HasGet for T

Source§

fn get_impl<T>(self, segment: impl Into<String>) -> Option<T>
where Self: HasBranches<T> + Sized, T: HasPathSegment,

Gets a branch by its path segment. It’s discouraged to use this method directly. Instead, use the get and get_mut method from the HasGetAPI trait.
Source§

impl<'a, T> HasGetAPI<'a> for T

Source§

fn get<T>(&'a self, segment: impl Into<String>) -> Option<T>
where &'a Self: HasGet + HasBranches<T>, T: HasPathSegment + 'a,

Gets a branch by its path segment.
Source§

impl<'a, T> HasRelative<'a> for T

Source§

fn relative<K>(&'a self, path: impl IntoIterator<Item = K>) -> Option<Self>
where K: Into<String>, Self: KnowsVisitor<Visitor = Self> + Clone + HasRoot + HasParent + HasPathSegment, &'a Self: HasBranches<Self>,

Gets a relative path. “self”, “root”, and “super” are reserved path segments. “self” is the current object, “root” is the root object, and “super” is the parent object.
Source§

impl<'a, T> HasRelativeMut<'a> for T

Source§

unsafe fn relative_mut<K>( &'a mut self, path: impl IntoIterator<Item = K>, ) -> Option<Self>
where K: Into<String>, Self: KnowsVisitor<VisitorMut = Self> + UnsafeClone + HasRootMut + HasParentMut + HasPathSegment + Sized, &'a mut Self: HasBranches<Self>,

Gets a relative path mutably. “self”, “root”, and “super” are reserved path segments. “self” is the current object, “root” is the root object, and “super” is the parent object.
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.