Skip to main content

NovaStr

Struct NovaStr 

Source
#[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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more