pub struct IdentPath {
pub segments: NonEmpty<Ident>,
}Expand description
A non-empty dot-separated identifier path in expression position.
Fields§
§segments: NonEmpty<Ident>Implementations§
Source§impl IdentPath
impl IdentPath
Sourcepub const fn new(segments: NonEmpty<Ident>) -> Self
pub const fn new(segments: NonEmpty<Ident>) -> Self
Construct a path from already-tokenized segments.
Sourcepub fn into_segments(self) -> NonEmpty<Ident>
pub fn into_segments(self) -> NonEmpty<Ident>
Consume and return the non-empty segment sequence.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns false; provided for API compatibility with sequence-like code.
Sourcepub fn to_name_path(&self) -> NamePath
pub fn to_name_path(&self) -> NamePath
The written path with per-segment spans dropped.
Use this for span-independent written identity (semantic metadata
keys); keep the IdentPath itself when diagnostics need segment spans.
Sourcepub fn split_last(&self) -> (&[Ident], &Ident)
pub fn split_last(&self) -> (&[Ident], &Ident)
Split the path into qualifier segments and the leaf segment.
The qualifier slice is empty for one-segment paths.
Sourcepub fn qualifier_segments(&self) -> &[Ident]
pub fn qualifier_segments(&self) -> &[Ident]
Returns the qualifier segments before the leaf. Empty for bare paths.
Sourcepub fn qualifier_and_leaf(&self) -> Option<(&[Ident], &Ident)>
pub fn qualifier_and_leaf(&self) -> Option<(&[Ident], &Ident)>
Returns qualifier segments and leaf only when this path is qualified.
Sourcepub fn as_bare(&self) -> Option<&Ident>
pub fn as_bare(&self) -> Option<&Ident>
Returns the only segment when this is a bare identifier path.
Sourcepub fn as_bare_mut(&mut self) -> Option<&mut Ident>
pub fn as_bare_mut(&mut self) -> Option<&mut Ident>
Mutably returns the only segment when this is a bare identifier path.
Sourcepub fn into_bare(self) -> Result<Ident, Self>
pub fn into_bare(self) -> Result<Ident, Self>
Consume this path and return its segment when it is bare.
Returns the original path unchanged when it is qualified.
Sourcepub fn into_name_path(self) -> NamePath
pub fn into_name_path(self) -> NamePath
Convert this spanned syntax path into a span-less NamePath.
Sourcepub fn into_spanned_name_path(self) -> Spanned<NamePath>
pub fn into_spanned_name_path(self) -> Spanned<NamePath>
Convert this syntax path into a NamePath paired with the path’s full span.
Sourcepub fn display_path(&self) -> String
pub fn display_path(&self) -> String
Human-readable path string for diagnostics and formatting boundaries.
Trait Implementations§
impl Eq for IdentPath
Source§impl FormatEquivalent for IdentPath
impl FormatEquivalent for IdentPath
Source§fn format_equivalent(&self, other: &Self) -> bool
fn format_equivalent(&self, other: &Self) -> bool
true if self and other are equivalent up to formatting.impl StructuralPartialEq for IdentPath
Auto Trait Implementations§
impl Freeze for IdentPath
impl RefUnwindSafe for IdentPath
impl Send for IdentPath
impl Sync for IdentPath
impl Unpin for IdentPath
impl UnsafeUnpin for IdentPath
impl UnwindSafe for IdentPath
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.