Skip to main content

WELL_KNOWN_SYMBOLS

Constant WELL_KNOWN_SYMBOLS 

Source
pub const WELL_KNOWN_SYMBOLS: &[&str];
Expand description

Which variant a heap object is, carrying none of its contents.

Property access has to pick a branch by variant, but the code inside a branch re-enters the host (bound_method, lookup_chain, invoke), so it cannot hold a &JsObj borrow across the match. The way out used to be h.get(v).cloned() — which deep-copies the entire backing store (a whole Vec<Value>, IndexMap, or String) just to read its tag. That made one property read O(len) and any loop over a collection O(n^2). This type is the same discriminant with nothing attached, so the probe is O(1) and each branch re-borrows for only the one field it actually needs. The well-known symbols node-js actually honors. Symbol.<name> is the interned symbol @@Symbol.<name>, and using it as a property key stores under the sentinel string @@<name> (property_key) so the internal lookups (@@iterator, @@toPrimitive, …) can find it without a symbol table walk. Symbols V8 defines but node-js does not act on are deliberately absent: a symbol that reads back while the operator it names ignores it would be a silent fake. hasInstance is listed because instance_of consults it.