pub struct LuaStringImpl { /* private fields */ }Expand description
A Lua string: an immutable, reference-counted byte sequence.
Short strings (<= MAX_SHORT_LEN = 40 bytes) are interned in the
StringPool on GlobalState; two short strings with the same bytes
are guaranteed to be the same GcRef (pointer equality via Rc::ptr_eq).
Long strings are heap-allocated independently and never interned. Their
hash is computed lazily on first call to [hash_long_str] and cached via
interior mutability (Cell<u32>).
§C mapping (types.tsv)
TString → LuaStringImpl
TString.extra → extra: Cell<u8> (reserved-word idx for Short; hash-ready flag for Long)
TString.shrlen → kind: StringKind (0xFF sentinel replaced by enum variant)
TString.hash → hash: Cell<u32>
TString.u.lnglen → bytes.len() (length implicit in Rc<[u8]>)
TString.u.hnext → (removed) (intrusive chain gone; StringPool uses HashMap)
TString.contents → bytes: Rc<[u8]>Implementations§
Source§impl LuaStringImpl
impl LuaStringImpl
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the string’s bytes.
macros.tsv: getstr / getlngstr / getshrstr → ts.as_bytes()
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the byte length of the string.
for Long. In Rust both cases are bytes.len().
macros.tsv: tsslen → ts.len()
Sourcepub fn is_reserved_word(&self) -> bool
pub fn is_reserved_word(&self) -> bool
Returns true if this short string is a Lua reserved word.
macros.tsv: isreserved → ts.is_reserved_word()
Sourcepub fn is_white(&self) -> bool
pub fn is_white(&self) -> bool
GC color predicate. Returns true if this object is “white” (unreachable)
in the GC’s current wave.
macros.tsv: iswhite → obj.is_white()
PORT NOTE: GC color management is deferred to Phase D. In Phases A–C all
objects are reachable via Rc reference counts and this always returns
false (nothing is white / unreachable).
Sourcepub fn flip_white(&self)
pub fn flip_white(&self)
Flip GC color from white to the current non-white (resurrect a dead object).
macros.tsv: changewhite → obj.flip_white()
PORT NOTE: GC color management deferred to Phase D; no-op in Phases A–C.
Trait Implementations§
Source§impl PartialEq for LuaStringImpl
impl PartialEq for LuaStringImpl
Source§impl Trace for LuaStringImpl
Phase-B internal richer LuaString. The byte buffer is a Rust Rc<[u8]>
(not GC-managed); no fields to mark.
impl Trace for LuaStringImpl
Phase-B internal richer LuaString. The byte buffer is a Rust Rc<[u8]>
(not GC-managed); no fields to mark.