pub struct JsSymbol { /* private fields */ }Expand description
A JavaScript symbol, stored on the GC heap.
A symbol is a unique property key that is not a string. Its identity is the
allocation, not the description: Symbol("a") !== Symbol("a"), and two symbols with
the same description still key two different properties. Only Symbol.for produces
the same symbol twice, and it does so by looking the key up in the realm’s registry
rather than by comparing descriptions.
Implementations§
Source§impl JsSymbol
impl JsSymbol
Sourcepub fn registered(key: String) -> JsSymbol
pub fn registered(key: String) -> JsSymbol
The registry entry for key, as Symbol.for returns it.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
The description, if there is one.
Sourcepub fn registry_key(&self) -> Option<&str>
pub fn registry_key(&self) -> Option<&str>
The registry key, if this symbol came from Symbol.for.
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Symbol.prototype.toString: Symbol(description).
A description is inserted verbatim, so Symbol("a)b").toString() is
Symbol(a)b) — the spec does not escape it.
Trait Implementations§
Auto Trait Implementations§
impl Forget for JsSymbol
impl Freeze for JsSymbol
impl Move for JsSymbol
impl RefUnwindSafe for JsSymbol
impl Send for JsSymbol
impl Sync for JsSymbol
impl Unpin for JsSymbol
impl UnsafeUnpin for JsSymbol
impl UnwindSafe for JsSymbol
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
Mutably borrows from an owned value. Read more