Skip to main content

LuaStringImpl

Struct LuaStringImpl 

Source
pub struct LuaStringImpl { /* private fields */ }
Expand description

A Lua string: an immutable, reference-counted byte sequence. Corresponds to C’s TString.

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). In practice the only LuaStringImpl ever created is the bootstrap OOM message — see the module doc.

Long strings are heap-allocated independently and never interned. hash is set once at construction in [create_str_obj], not computed lazily.

Implementations§

Source§

impl LuaStringImpl

Source

pub fn as_bytes(&self) -> &[u8]

Returns the string’s bytes.

Source

pub fn len(&self) -> usize

Returns the byte length of the string.

Source

pub fn is_long(&self) -> bool

Returns true if this is a long (non-interned) string.

Source

pub fn is_short(&self) -> bool

Returns true if this is a short (interned) string.

Source

pub fn is_reserved_word(&self) -> bool

Returns true if this short string is a Lua reserved word.

Source

pub fn is_white(&self) -> bool

GC color predicate. LuaStringImpl values are never registered with the tracing collector (see the module doc), so this always returns false.

Source

pub fn flip_white(&self)

Flip GC color from white to the current non-white (resurrect a dead object). No-op; see Self::is_white.

Trait Implementations§

Source§

impl Eq for LuaStringImpl

Source§

impl PartialEq for LuaStringImpl

Source§

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

Equality for Lua strings.

For short strings (interned), pointer equality via Rc::ptr_eq is sufficient and matches eqshrstr in C. For long strings, we fall back to byte comparison, matching luaS_eqlngstr in C.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Trace for LuaStringImpl

The byte buffer is a Rust Rc<[u8]> (not GC-managed); no fields to mark.

Source§

fn type_name(&self) -> &'static str

Concrete Rust type name for diagnostic/testC telemetry (Heap::type_name_count). Collector behavior must not branch on this. The default covers container blanket impls, which are never GC-boxed directly; concrete runtime types override it with std::any::type_name::<Self>().
Source§

fn trace(&self, _m: &mut Marker)

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.