pub struct NameDef<Ns: NameNamespace> { /* private fields */ }Expand description
A definition-site leaf name in a semantic namespace.
NameDef<Ns> is intentionally a single NameAtom. It is suitable for
names introduced by syntax positions whose namespace is fixed by the
grammar, such as type Foo, index Phase, or unit m. Reference positions
that may be qualified should stay as NamePath
/ IdentPath until module-aware
resolution can produce a ResolvedName.
Implementations§
Source§impl<Ns: NameNamespace> NameDef<Ns>
impl<Ns: NameNamespace> NameDef<Ns>
Sourcepub fn new(s: impl Into<String>) -> Self
pub fn new(s: impl Into<String>) -> Self
Create a new leaf name from a string.
§Panics
Panics if the string is empty or contains .. Use Self::try_new
when validating external input.
Sourcepub fn try_new(s: impl Into<String>) -> Result<Self, NameAtomError>
pub fn try_new(s: impl Into<String>) -> Result<Self, NameAtomError>
Try to create a new leaf name from a string.
§Errors
Returns NameAtomError when the string is empty or contains a path
separator.
Sourcepub const fn from_atom(atom: NameAtom) -> Self
pub const fn from_atom(atom: NameAtom) -> Self
Create this namespace-specific name from an existing atom.
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consume and return the inner String.
Source§impl NameDef<IndexVariant>
impl NameDef<IndexVariant>
Sourcepub fn range_step(n: impl Display) -> Self
pub fn range_step(n: impl Display) -> Self
Build the variant name for the n-th step of a range index
(#0, #1, …). Centralises the "#"-prefix format so registry,
parser, and evaluator can’t disagree on it.
Sourcepub fn qualified_by(&self, index: &IndexName) -> QualifiedIndexVariantName
pub fn qualified_by(&self, index: &IndexName) -> QualifiedIndexVariantName
Pair this variant with its index name for qualified rendering.
Trait Implementations§
Source§impl<Ns: NameNamespace> Debug for NameDef<Ns>
impl<Ns: NameNamespace> Debug for NameDef<Ns>
Source§impl<Ns: NameNamespace> Display for NameDef<Ns>
impl<Ns: NameNamespace> Display for NameDef<Ns>
impl<Ns: Eq + NameNamespace> Eq for NameDef<Ns>
Source§impl From<NameDef<Unit>> for UnitRef
impl From<NameDef<Unit>> for UnitRef
Source§fn from(name: UnitName) -> Self
fn from(name: UnitName) -> Self
Wrap a bare unit name as a local reference. Definition sites always
produce local references; qualified forms are constructed explicitly
via UnitRef::qualified.
Source§impl<Ns: Ord + NameNamespace> Ord for NameDef<Ns>
impl<Ns: Ord + NameNamespace> Ord for NameDef<Ns>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<Ns: PartialEq + NameNamespace> PartialEq for NameDef<Ns>
impl<Ns: PartialEq + NameNamespace> PartialEq for NameDef<Ns>
Source§impl<Ns: PartialOrd + NameNamespace> PartialOrd for NameDef<Ns>
impl<Ns: PartialOrd + NameNamespace> PartialOrd for NameDef<Ns>
impl<Ns: NameNamespace> StructuralPartialEq for NameDef<Ns>
Auto Trait Implementations§
impl<Ns> Freeze for NameDef<Ns>
impl<Ns> RefUnwindSafe for NameDef<Ns>where
Ns: RefUnwindSafe,
impl<Ns> Send for NameDef<Ns>where
Ns: Send,
impl<Ns> Sync for NameDef<Ns>where
Ns: Sync,
impl<Ns> Unpin for NameDef<Ns>where
Ns: Unpin,
impl<Ns> UnsafeUnpin for NameDef<Ns>
impl<Ns> UnwindSafe for NameDef<Ns>where
Ns: UnwindSafe,
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.