pub struct Ident(/* private fields */);Expand description
An interned identifier.
Implementations§
Source§impl Ident
impl Ident
pub fn new(s: impl AsRef<str>) -> Self
pub fn into_label(self) -> String
Sourcepub fn fresh() -> Self
pub fn fresh() -> Self
Create a new fresh identifier. This identifier is unique and is guaranteed not to collide with any identifier defined before.
Generated identifiers start with a special prefix that isn’t valid
for Nickel identifiers. This doesn’t actually guarantee that the
label of a fresh identifier will always be different
from the label of a normal identifier created by Ident::new: there
are ways to introduce normal identifiers that aren’t parsed as Nickel
identifiers (for example, std.record.insert "%1" 42 {} causes an
identifier to be created with the name “%1”).
The consequence of all this is that different Idents can have the
same label. Ident::new("%1") and Ident::fresh() might both generate
idents with label “%1”, but they will be different idents.
Sourcepub fn spanned(self, pos: TermPos) -> LocIdent
pub fn spanned(self, pos: TermPos) -> LocIdent
Attaches a position to this identifier, making it a LocIdent.
Sourcepub fn is_generated(&self) -> bool
pub fn is_generated(&self) -> bool
Checks whether this identifier was generated with Ident::fresh.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ident
impl<'de> Deserialize<'de> for Ident
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Ident
impl Ord for Ident
Source§impl PartialOrd for Ident
impl PartialOrd for Ident
impl Allocable for Ident
impl Copy for Ident
impl Eq for Ident
impl StructuralPartialEq for Ident
Auto Trait Implementations§
impl Freeze for Ident
impl RefUnwindSafe for Ident
impl Send for Ident
impl Sync for Ident
impl Unpin for Ident
impl UnsafeUnpin for Ident
impl UnwindSafe for Ident
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more