pub struct UnitRef { /* private fields */ }Expand description
A unit reference, optionally qualified by a module alias.
Unit references follow the same scoping rules as every other imported
category: a bare name (mile) refers to a local declaration, a selective
import, or a prelude unit; a qualified name (u.mile) refers to a pub
unit of the module imported as u. The qualifier is at most one module
alias — unit references never nest deeper.
The Display impl renders u.mile / mile for diagnostics and
formatting boundaries only; the compiler core matches on the typed parts.
Implementations§
Source§impl UnitRef
impl UnitRef
Sourcepub fn local(name: impl Into<UnitName>) -> Self
pub fn local(name: impl Into<UnitName>) -> Self
Create an unqualified (file-local, selective-import, or prelude) unit reference.
Sourcepub const fn qualified(qualifier: ModuleAliasName, name: UnitName) -> Self
pub const fn qualified(qualifier: ModuleAliasName, name: UnitName) -> Self
Create a unit reference qualified by a module alias (u.mile).
Sourcepub const fn qualifier(&self) -> Option<&ModuleAliasName>
pub const fn qualifier(&self) -> Option<&ModuleAliasName>
The module alias qualifying this reference, if any.
Sourcepub const fn is_qualified(&self) -> bool
pub const fn is_qualified(&self) -> bool
Returns whether this reference is module-qualified.
Trait Implementations§
impl Eq for UnitRef
Source§impl FormatEquivalent for UnitRef
impl FormatEquivalent for UnitRef
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 UnitRef
impl From<NameAtom> for UnitRef
Source§fn from(atom: NameAtom) -> Self
fn from(atom: NameAtom) -> Self
Wrap a bare atom as a local unit reference. This is what
crate::syntax::ast::Ident::into_spanned uses to lift parser
identifiers into the typed reference.
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 Ord for UnitRef
impl Ord for UnitRef
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 UnitRef
impl PartialOrd for UnitRef
impl StructuralPartialEq for UnitRef
Auto Trait Implementations§
impl Freeze for UnitRef
impl RefUnwindSafe for UnitRef
impl Send for UnitRef
impl Sync for UnitRef
impl Unpin for UnitRef
impl UnsafeUnpin for UnitRef
impl UnwindSafe for UnitRef
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.