use crate::{ImmutableString, Position};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{borrow::Borrow, fmt, hash::Hash};
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct Ident {
pub name: ImmutableString,
pub pos: Position,
}
impl fmt::Debug for Ident {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.name)?;
self.pos.debug_print(f)
}
}
impl Borrow<str> for Ident {
#[inline(always)]
#[must_use]
fn borrow(&self) -> &str {
self.name.as_ref()
}
}
impl AsRef<str> for Ident {
#[inline(always)]
#[must_use]
fn as_ref(&self) -> &str {
self.name.as_ref()
}
}
impl Ident {
#[inline(always)]
#[must_use]
pub fn as_str(&self) -> &str {
self.name.as_str()
}
#[inline(always)]
#[must_use]
pub fn is_empty(&self) -> bool {
self.name.is_empty()
}
}