pub struct Path {
pub full_path: Fragment,
pub head: Identifier,
pub tail: Vec<Identifier>,
}Available on crate feature
ast-models only.Expand description
A double-colon separated path/reference to a module/function. This can be used in an import declaration and
some other places. Paths with length of 1 are just Identifiers – Identifiers can be considered paths in some
instances.
Fields§
§full_path: FragmentThe Fragment of source code containing the full source of this path (including the double-colon separators).
head: IdentifierThe first (left-most) identifier in this Path. This can also be considered the “root” of the path – the module that the following item/identifier can be found in.
tail: Vec<Identifier>The rest of the Path, following the first separator.
Implementations§
Source§impl Path
impl Path
Sourcepub fn segments(&self) -> impl Iterator<Item = &Identifier>
pub fn segments(&self) -> impl Iterator<Item = &Identifier>
Iterate over all the segments of this path, starting with Path::head.
Sourcepub fn last(&self) -> &Identifier
pub fn last(&self) -> &Identifier
Get the last segment of this path (the name of the item it refers to).
Sourcepub fn as_identifier(&self) -> Option<&Identifier>
pub fn as_identifier(&self) -> Option<&Identifier>
If this path is a single identifier, get it.
Trait Implementations§
Source§impl AstNode for Path
impl AstNode for Path
Source§fn matching_source(&self) -> &Fragment
fn matching_source(&self) -> &Fragment
Get the Fragment of source code this node was parsed from.
impl StructuralPartialEq for Path
Auto Trait Implementations§
impl Forget for Path
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more