Struct Name
pub struct Name(/* private fields */);Expand description
new type over identifier names
This is a simple String representing an identifier name. In the future, we
might want to introduce interning (either on Name or QualName). The inner
String is private so that such a change stays local to this module; reach
for Name::new, as_str, From<&str>, or Display instead of the field.
Names are ordered by their text, byte by byte. For UTF-8 that is the order of the
code points, and a name that another begins with comes first: the label order a
record type’s fields are kept in once canonicalized (docs/spec/records.md,
Records and derivation).
Implementations§
§impl Name
impl Name
pub fn qualify_with(self, s: String) -> Name
pub fn qualify_with(self, s: String) -> Name
Qualify the existing name with a module: Size qualified with AcmeWidgets is
AcmeWidgets.Size.
The result is a spelling — what a source file writes to reach a name through a
module, an alias or a namespace — and not an identity, which is why it is a
Name and not a zelkova_compiler::name::QualName: a spelling says nothing about
which package declared what it reaches.
pub fn last_segment(&self) -> Name
pub fn last_segment(&self) -> Name
The last dot-separated segment of this name: add of Js.Basics.add, and the
whole name when it has no dot.
A qualified spelling names a declaration by its own name in its last segment, whatever module or alias the segments before it wrote.
pub fn starts_with(&self, other: &Name) -> bool
Trait Implementations§
impl Eq for Name
§impl Ord for Name
impl Ord for Name
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialOrd for Name
impl PartialOrd for Name
impl StructuralPartialEq for Name
Auto Trait Implementations§
impl Freeze for Name
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnsafeUnpin for Name
impl UnwindSafe for Name
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.