#[repr(C)]pub struct NovaStr {
pub len: u64,
pub ptr: *const u8,
}Expand description
A Nova string value: immutable UTF-8, { len, ptr }.
A runtime-made String or Bytes value is one leaf GC object: this
header at offset 0, and its bytes inline at offset 16, where ptr points
([alloc_str_object]). A string literal’s header from
nova_rt_str_new is a 16-byte leaf whose ptr targets static data.
Invariant: ptr never points into another GC object. Every header is
a leaf, so the collector never traces ptr. A header that pointed into a
different GC object would not keep it alive. A future zero-copy slice or
view must not reuse this type with a leaf header. Only
[alloc_str_object] and nova_rt_str_new write a ptr, and nothing
in this crate’s production code calls nova_rt_str_new. The test
only_the_two_builders_write_a_novastr_ptr checks both by scanning the
source text; its doc names some of what such a scan cannot see. What the
code generators pass to nova_rt_str_new rests on its # Safety
contract.
A convention, not an invariant: [gc_str_filled]’s fill does not
allocate GC memory. Memory safety does not depend on it, since the new
object stays reachable from gc_str_filled’s own frame across fill.
It keeps fill cheap, and its liveness argument to the one allocation
before it. Every current writer only calls [Fill::put].
Fields§
§len: u64§ptr: *const u8