Skip to main content

NamePath

Struct NamePath 

Source
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

Source

pub const fn new(segments: NonEmpty<NameAtom>) -> Self

Construct a path from already-validated atoms.

Source

pub fn local(atom: NameAtom) -> Self

Construct a one-segment path.

Source

pub fn qualified_path( qualifier: impl IntoIterator<Item = NameAtom>, leaf: NameAtom, ) -> Self

Construct a path from qualifier atoms plus a leaf atom.

Source

pub fn segments(&self) -> &[NameAtom]

Borrow all path segments in source order.

Source

pub fn into_segments(self) -> NonEmpty<NameAtom>

Consume and return all path segments.

Source

pub const fn len(&self) -> usize

Number of path segments. Always at least 1.

Source

pub const fn is_empty(&self) -> bool

Returns false; provided for API compatibility with sequence-like code.

Source

pub const fn is_bare(&self) -> bool

Returns whether this is a one-segment path.

Source

pub fn leaf(&self) -> &NameAtom

Returns the leaf segment.

Source

pub fn as_bare(&self) -> Option<&NameAtom>

Returns the only segment when this is a bare path.

Source

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.

Source

pub fn qualifier_segments(&self) -> &[NameAtom]

Returns the qualifier segments before the leaf. Empty for bare paths.

Source

pub fn qualifier_and_leaf(&self) -> Option<(&[NameAtom], &NameAtom)>

Returns qualifier segments and leaf only when this path is qualified.

Source

pub fn display_path(&self) -> String

Human-readable path string for diagnostics and formatting boundaries.

Trait Implementations§

Source§

impl Clone for NamePath

Source§

fn clone(&self) -> NamePath

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NamePath

Source§

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

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

impl Display for NamePath

Source§

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

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

impl Eq for NamePath

Source§

impl FormatEquivalent for NamePath

Source§

fn format_equivalent(&self, other: &Self) -> bool

Returns true if self and other are equivalent up to formatting.
Source§

impl From<&str> for NamePath

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<NameAtom> for NamePath

Source§

fn from(atom: NameAtom) -> Self

Converts to this type from the input type.
Source§

impl From<NameDef<Index>> for NamePath

Source§

fn from(name: IndexName) -> Self

Converts to this type from the input type.
Source§

impl From<NamePath> for MapEntryIndex

Source§

fn from(value: NamePath) -> Self

Converts to this type from the input type.
Source§

impl From<String> for NamePath

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for NamePath

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for NamePath

Source§

fn cmp(&self, other: &NamePath) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for NamePath

Source§

fn eq(&self, other: &NamePath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for NamePath

Source§

fn partial_cmp(&self, other: &NamePath) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for NamePath

Auto Trait Implementations§

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.