[][src]Struct spinoso_symbol::Symbol

pub struct Symbol(_);

Identifier bound to an interned bytestring.

A Symbol allows retrieving a reference to the original interned bytestring. Equivalent Symbols will resolve to an identical bytestring.

Symbols are based on a u32 index. They are cheap to compare and cheap to copy.

Symbols are not constrained to the interner which created them.

Implementations

impl Symbol[src]

#[must_use]pub const fn new(id: u32) -> Self[src]

Construct a new Symbol from the given u32.

Symbols constructed manually may fail to resolve to an underlying bytesstring.

Symbols are not constrained to the interner which created them. No runtime checks ensure that the underlying interner is called with a Symbol that the interner itself issued.

Examples

let sym = Symbol::new(263);
assert_eq!(sym.id(), 263);

#[must_use]pub const fn id(self) -> u32[src]

Return the u32 identifier from this Symbol.

Examples

let sym = Symbol::new(263);
assert_eq!(sym.id(), 263);
assert_eq!(u32::from(sym), 263);

#[must_use]pub fn is_empty<T, U>(self, interner: &T) -> bool where
    T: Intern<Symbol = U>,
    U: Copy + From<Symbol>, 
[src]

This is supported on crate feature artichoke only.

Returns whether the symbol is the empty byteslice b"" in the underlying interner.

If there symbol does not exist in the underlying interner or there is an error looking up the symbol in the underlying interner, true is returned.

#[must_use]pub fn len<T, U>(self, interner: &T) -> usize where
    T: Intern<Symbol = U>,
    U: Copy + From<Symbol>, 
[src]

This is supported on crate feature artichoke only.

Returns the length of the byteslice associated with the symbol in the underlying interner.

If there symbol does not exist in the underlying interner or there is an error looking up the symbol in the underlying interner, 0 is returned.

#[must_use]pub fn bytes<T, U>(self, interner: &T) -> &[u8] where
    T: Intern<Symbol = U>,
    U: Copy + From<Symbol>, 
[src]

This is supported on crate feature artichoke only.

Returns the interned byteslice associated with the symbol in the underlying interner.

If there symbol does not exist in the underlying interner or there is an error looking up the symbol in the underlying interner, &[] is returned.

pub fn inspect<T, U>(self, interner: &T) -> Inspect<'_>

Notable traits for Inspect<'a>

impl<'a> Iterator for Inspect<'a> type Item = char;
where
    T: Intern<Symbol = U>,
    U: Copy + From<Symbol>, 
[src]

This is supported on crate feature artichoke only.

Returns an iterator that yields a debug representation of the interned byteslice associated with the symbol in the underlying interner.

This iterator produces char sequences like :spinoso and :"invalid-\xFF-utf8".

If there symbol does not exist in the underlying interner or there is an error looking up the symbol in the underlying interner, a default iterator is returned.

Trait Implementations

impl Borrow<u32> for Symbol[src]

impl Clone for Symbol[src]

impl Copy for Symbol[src]

impl Debug for Symbol[src]

impl Eq for Symbol[src]

impl From<&'_ NonZeroU16> for Symbol[src]

impl From<&'_ NonZeroU32> for Symbol[src]

impl From<&'_ NonZeroU8> for Symbol[src]

impl From<&'_ u16> for Symbol[src]

impl From<&'_ u32> for Symbol[src]

impl From<&'_ u8> for Symbol[src]

impl From<NonZeroU16> for Symbol[src]

impl From<NonZeroU32> for Symbol[src]

impl From<NonZeroU8> for Symbol[src]

impl From<u16> for Symbol[src]

impl From<u32> for Symbol[src]

impl From<u8> for Symbol[src]

impl Hash for Symbol[src]

impl Ord for Symbol[src]

impl PartialEq<&'_ u32> for Symbol[src]

impl PartialEq<Symbol> for Symbol[src]

impl PartialEq<u32> for Symbol[src]

impl PartialEq<u32> for &Symbol[src]

impl PartialOrd<Symbol> for Symbol[src]

impl StructuralEq for Symbol[src]

impl StructuralPartialEq for Symbol[src]

impl TryFrom<&'_ NonZeroU64> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<&'_ NonZeroUsize> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<&'_ u64> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<&'_ usize> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<NonZeroU64> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<NonZeroUsize> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<u64> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

impl TryFrom<usize> for Symbol[src]

type Error = SymbolOverflowError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Symbol[src]

impl Send for Symbol[src]

impl Sync for Symbol[src]

impl Unpin for Symbol[src]

impl UnwindSafe for Symbol[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.