Skip to main content

Identifier

Struct Identifier 

Source
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>

Source

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.

Source

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.

Source

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

Source

pub fn check_validity(&self) -> Result<(), Error>

Source

pub fn to_case(&self, case: Case<'_>) -> String

Convert the identifier to a string in the given case

Source

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.

Source

pub fn words_display(&self) -> String

Get a display string that separates the words that make up the identifier visually

Source

pub fn words_display_prepended(&self, word: String) -> String

Same as Self::words_display, but prepends another word

Source

pub fn is_empty(&self) -> bool

Source

pub fn take_ref(&self) -> IdentifierRef<T>
where T: Clone,

Get a type ref if this is a type identifier

Source

pub fn set_duplicate_id(&mut self, val: NonZeroU32)

Source

pub fn duplicate_id(&self) -> Option<NonZeroU32>

Source

pub fn to_runtime_type(self) -> Identifier<RuntimeType>

Source

pub fn as_runtime_type_mut(&mut self) -> &mut Identifier<RuntimeType>

Source

pub fn as_runtime_type(&self) -> &Identifier<RuntimeType>

Source

pub fn id_type(&self) -> &T

Get the identifier type

Source

pub fn cast<U>(self) -> Identifier<U>
where U: IdentifierType + Default + From<T>,

Change the type of the identifier to a more specific type

Source

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.

Source

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>

Source§

fn clone(&self) -> Identifier<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + IdentifierType> Debug for Identifier<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: IdentifierType + Default> Default for Identifier<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: IdentifierType> Eq for Identifier<T>

Source§

impl<T: IdentifierType> Hash for Identifier<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: IdentifierType> PartialEq for Identifier<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T> SpanExt for T

Source§

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,

Same as Self::with_span, but can avoid name collisions
Source§

fn with_dummy_span(self) -> Spanned<Self>
where Self: Sized,

Source§

fn into_with_dummy_span<T>(self) -> Spanned<T>
where Self: Into<T>,

Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.