pub struct ScopedName { /* private fields */ }Expand description
A declaration name that may optionally be qualified by a module path.
The qualifier is stored as structured path segments, not as a flat
dot-separated string. This allows arbitrary-depth qualification such as
helpers.math.G0 while keeping the declaration member (G0) directly
accessible and distinct from the qualifier.
The Display impl renders qualifier: ["helpers", "math"], member: "G0"
as helpers.math.G0. That serialized form is for boundary use only
(diagnostics, debug output, third-party APIs); the compiler core should use
the typed accessors instead of splitting strings.
Implementations§
Source§impl ScopedName
impl ScopedName
Sourcepub fn qualified(
module: impl Into<Arc<str>>,
member: impl Into<Arc<str>>,
) -> Self
pub fn qualified( module: impl Into<Arc<str>>, member: impl Into<Arc<str>>, ) -> Self
Create a name qualified by a single module segment.
Sourcepub fn qualified_path(
qualifier: impl IntoIterator<Item = impl Into<Arc<str>>>,
member: impl Into<Arc<str>>,
) -> Self
pub fn qualified_path( qualifier: impl IntoIterator<Item = impl Into<Arc<str>>>, member: impl Into<Arc<str>>, ) -> Self
Create a name qualified by an arbitrary-depth module path.
Sourcepub fn member(&self) -> &str
pub fn member(&self) -> &str
Returns the member (leaf declaration) part of the name.
For x this returns "x"; for helpers.math.x this also returns
"x".
Sourcepub fn qualifier(&self) -> &[Arc<str>]
pub fn qualifier(&self) -> &[Arc<str>]
Returns the qualifier path segments. Empty means this name is local.
Sourcepub fn is_qualified(&self) -> bool
pub fn is_qualified(&self) -> bool
Returns whether this is a qualified name.
Sourcepub fn with_prefix(&self, prefix: &str) -> Self
pub fn with_prefix(&self, prefix: &str) -> Self
Qualify a name with a single-segment prefix, replacing any existing qualifier while preserving the member.
x.with_prefix("p") → p.x.
m.x.with_prefix("p") → p.x.
Trait Implementations§
Source§impl Clone for ScopedName
impl Clone for ScopedName
Source§fn clone(&self) -> ScopedName
fn clone(&self) -> ScopedName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScopedName
impl Debug for ScopedName
Source§impl Display for ScopedName
impl Display for ScopedName
impl Eq for ScopedName
Source§impl FormatEquivalent for ScopedName
impl FormatEquivalent for ScopedName
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<NameAtom> for ScopedName
impl From<NameAtom> for ScopedName
Source§fn from(atom: NameAtom) -> Self
fn from(atom: NameAtom) -> Self
Wrap a bare atom as a local ScopedName. This is what
crate::syntax::ast::Ident::into_spanned uses to lift parser
identifiers into the typed name; qualified forms are constructed
explicitly via ScopedName::qualified or ScopedName::qualified_path.
Source§impl From<String> for ScopedName
impl From<String> for ScopedName
Source§impl Hash for ScopedName
impl Hash for ScopedName
Source§impl Ord for ScopedName
impl Ord for ScopedName
Source§fn cmp(&self, other: &ScopedName) -> Ordering
fn cmp(&self, other: &ScopedName) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ScopedName
impl PartialEq for ScopedName
Source§fn eq(&self, other: &ScopedName) -> bool
fn eq(&self, other: &ScopedName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ScopedName
impl PartialOrd for ScopedName
impl StructuralPartialEq for ScopedName
Auto Trait Implementations§
impl Freeze for ScopedName
impl RefUnwindSafe for ScopedName
impl Send for ScopedName
impl Sync for ScopedName
impl Unpin for ScopedName
impl UnsafeUnpin for ScopedName
impl UnwindSafe for ScopedName
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.