pub struct NamePath { /* private fields */ }Expand description
A syntactic non-empty dot-separated name path.
NamePath preserves source-level path shape (Foo, module.Foo,
module.Index.Variant) without assigning a semantic namespace to any
segment. It is appropriate for unresolved reference positions that do not
need per-segment spans. Use crate::syntax::ast::IdentPath when the AST
must retain source spans for each segment.
Implementations§
Source§impl NamePath
impl NamePath
Sourcepub const fn new(segments: NonEmpty<NameAtom>) -> Self
pub const fn new(segments: NonEmpty<NameAtom>) -> Self
Construct a path from already-validated atoms.
Sourcepub fn qualified_path(
qualifier: impl IntoIterator<Item = NameAtom>,
leaf: NameAtom,
) -> Self
pub fn qualified_path( qualifier: impl IntoIterator<Item = NameAtom>, leaf: NameAtom, ) -> Self
Construct a path from qualifier atoms plus a leaf atom.
Sourcepub fn into_segments(self) -> NonEmpty<NameAtom>
pub fn into_segments(self) -> NonEmpty<NameAtom>
Consume and return all path segments.
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 split_last(&self) -> (&[NameAtom], &NameAtom)
pub fn split_last(&self) -> (&[NameAtom], &NameAtom)
Split the path into qualifier segments and leaf segment.
The qualifier slice is empty for one-segment paths.
Sourcepub fn qualifier_segments(&self) -> &[NameAtom]
pub fn qualifier_segments(&self) -> &[NameAtom]
Returns the qualifier segments before the leaf. Empty for bare paths.
Sourcepub fn qualifier_and_leaf(&self) -> Option<(&[NameAtom], &NameAtom)>
pub fn qualifier_and_leaf(&self) -> Option<(&[NameAtom], &NameAtom)>
Returns qualifier segments and leaf only when this path is qualified.
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 NamePath
Source§impl FormatEquivalent for NamePath
impl FormatEquivalent for NamePath
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.Source§impl From<NamePath> for MapEntryIndex
impl From<NamePath> for MapEntryIndex
Source§impl Ord for NamePath
impl Ord for NamePath
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NamePath
impl PartialOrd for NamePath
impl StructuralPartialEq for NamePath
Auto Trait Implementations§
impl Freeze for NamePath
impl RefUnwindSafe for NamePath
impl Send for NamePath
impl Sync for NamePath
impl Unpin for NamePath
impl UnsafeUnpin for NamePath
impl UnwindSafe for NamePath
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.