Struct Symbol

pub struct Symbol(pub(in ::bridge::symbol) NonZero<u32>);

Handle for a symbol string stored within the Interner.

Fields

0: NonZero<u32>

Implementations

impl Symbol

fn new(string: &str) -> Self

Intern a new Symbol

fn new_ident(string: &str, is_raw: bool) -> Self

Creates a new Symbol for an identifier.

Validates and normalizes before converting it to a symbol.

fn with<R>(self, f: impl FnOnce(&str) -> R) -> R

Run a callback with the symbol's string value.

fn invalidate_all()

Clear out the thread-local symbol interner, making all previously created symbols invalid such that with will panic when called on them.

fn is_valid_ascii_ident(bytes: &[u8]) -> bool

Checks if the ident is a valid ASCII identifier.

This is a short-circuit which is cheap to implement within the proc-macro client to avoid RPC when creating simple idents, but may return false for a valid identifier if it contains non-ASCII characters.

fn can_be_raw(string: &str) -> bool

Trait Implementations

impl !Send for Symbol

impl !Sync for Symbol

impl Clone for Symbol

fn clone(&self) -> Symbol

impl Copy for Symbol

impl Debug for Symbol

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

impl Display for Symbol

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

impl Eq for Symbol

fn assert_fields_are_eq(&self)

impl Hash for Symbol

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

impl PartialEq for Symbol

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

impl StructuralPartialEq for Symbol

impl TrivialClone for Symbol

impl<S> Decode<'_, '_, S> for Symbol

fn decode(r: &mut &[u8], s: &mut S) -> Self

impl<S> Encode<S> for Symbol

fn encode(self, w: &mut Buffer, s: &mut S)

Auto Trait Implementations

impl Freeze for Symbol

impl RefUnwindSafe for Symbol

impl Unpin for Symbol

impl UnsafeUnpin for Symbol

impl UnwindSafe for Symbol

Blanket Implementations

impl<T> Any for Symbol where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Symbol

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Printable for Symbol where T: Copy + Debug,

impl<T> SizeHint for Symbol where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Symbol

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for Symbol where T: Display + ?Sized,

fn to_string(&self) -> String

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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