pub struct Identifier<T: IdentifierType> { /* private fields */ }Expand description
A structure that holds the name data of objects
Implementations§
Source§impl<T: IdentifierType> Identifier<T>
impl<T: IdentifierType> Identifier<T>
Sourcepub fn try_parse(value: &str) -> Result<Self, Error>where
T: Default,
pub fn try_parse(value: &str) -> Result<Self, Error>where
T: Default,
Try parse a string as an identifier. It will not have boundaries applied yet.
Sourcepub fn try_parse_with_type(value: &str, id_type: T) -> Result<Self, Error>
pub fn try_parse_with_type(value: &str, id_type: T) -> Result<Self, Error>
Try parse a string as an identifier. It will not have boundaries applied yet.
Sourcepub fn apply_boundaries(&mut self, boundaries: &[Boundary]) -> &mut Self
pub fn apply_boundaries(&mut self, boundaries: &[Boundary]) -> &mut Self
Apply the boundaries. This can only be called once and must be called before Self::to_case
pub fn check_validity(&self) -> Result<(), Error>
Sourcepub fn to_case(&self, case: Case<'_>) -> String
pub fn to_case(&self, case: Case<'_>) -> String
Convert the identifier to a string in the given case
Sourcepub fn original(&self) -> &str
pub fn original(&self) -> &str
Get the original text. Don’t use this unless it’s important to get the exact original value.
Better to use Self::to_case in most circumstances.
Sourcepub fn words_display(&self) -> String
pub fn words_display(&self) -> String
Get a display string that separates the words that make up the identifier visually
Sourcepub fn words_display_prepended(&self, word: String) -> String
pub fn words_display_prepended(&self, word: String) -> String
Same as Self::words_display, but prepends another word
pub fn is_empty(&self) -> bool
Sourcepub fn take_ref(&self) -> IdentifierRef<T>where
T: Clone,
pub fn take_ref(&self) -> IdentifierRef<T>where
T: Clone,
Get a type ref if this is a type identifier
pub fn set_duplicate_id(&mut self, val: NonZeroU32)
pub fn duplicate_id(&self) -> Option<NonZeroU32>
pub fn to_runtime_type(self) -> Identifier<RuntimeType>
pub fn as_runtime_type_mut(&mut self) -> &mut Identifier<RuntimeType>
pub fn as_runtime_type(&self) -> &Identifier<RuntimeType>
Sourcepub fn cast<U>(self) -> Identifier<U>
pub fn cast<U>(self) -> Identifier<U>
Change the type of the identifier to a more specific type
Sourcepub fn cast_unchecked<U: IdentifierType + Default>(self) -> Identifier<U>
pub fn cast_unchecked<U: IdentifierType + Default>(self) -> Identifier<U>
Change the type of the identifier. This is generally a bad idea because of the subtleties! So make sure this is actually what you want.
Sourcepub fn cast_assert<U: IdentifierType + Default>(self) -> Identifier<U>
pub fn cast_assert<U: IdentifierType + Default>(self) -> Identifier<U>
Change the type of the identifier, but only if the runtime type is already that type. This function will panic if they’re different.
Trait Implementations§
Source§impl<T: Clone + IdentifierType> Clone for Identifier<T>
impl<T: Clone + IdentifierType> Clone for Identifier<T>
Source§fn clone(&self) -> Identifier<T>
fn clone(&self) -> Identifier<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug + IdentifierType> Debug for Identifier<T>
impl<T: Debug + IdentifierType> Debug for Identifier<T>
Source§impl<T: IdentifierType + Default> Default for Identifier<T>
impl<T: IdentifierType + Default> Default for Identifier<T>
impl<T: IdentifierType> Eq for Identifier<T>
Source§impl<T: IdentifierType> Hash for Identifier<T>
impl<T: IdentifierType> Hash for Identifier<T>
Auto Trait Implementations§
impl<T> Freeze for Identifier<T>where
T: Freeze,
impl<T> RefUnwindSafe for Identifier<T>where
T: RefUnwindSafe,
impl<T> Send for Identifier<T>where
T: Send,
impl<T> Sync for Identifier<T>where
T: Sync,
impl<T> Unpin for Identifier<T>where
T: Unpin,
impl<T> UnsafeUnpin for Identifier<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Identifier<T>where
T: 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> 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.impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T> SpanExt for T
impl<T> SpanExt for T
fn with_span(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
Source§fn spanned(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
fn spanned(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
Self::with_span, but can avoid name collisionsfn with_dummy_span(self) -> Spanned<Self>where
Self: Sized,
fn into_with_dummy_span<T>(self) -> Spanned<T>where
Self: Into<T>,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.