Expand description
ALTREP implementation utilities.
This module provides helper functions used by the declarative macros
generated for ALTREP classes. The proc-macro derives (#[derive(AltrepInteger)]
etc.) lower to invocations of impl_alt*_from_data! macros which expand
to code that references items in this module via $crate::altrep_impl::*
paths.
Use crate::altrep_data1_as (re-exported from externalptr) to extract
data from an ALTREP’s data1 slot.
§Layout
macros—#[macro_export]declarative macros (impl_alt*_from_data!and their__impl_*helpers).builtins— crate-private meta-macro + invocations forVec<T>/Box<[T]>/Cow<T>/Range<T>ALTREP families.arrays— const-generic[T; N]ALTREP impls.static_slices— hand-written&'static [T]ALTREP impls.
Modules§
- arrays
- ALTREP for owned const-generic arrays.
- buffers
- Registered native buffers with value duplication and retained allocations.
- builtins
- Built-in ALTREP class instantiations for
Vec<T>,Box<[T]>,Cow<T>, andRange<T>. - macros
- Declarative macros generating ALTREP trait implementations.
- shared_
slices - Shared slice owners with coordinated COW and duplicate policies.
- static_
slices - ALTREP impls for
&'static [T].
Functions§
- altlist_
set_ 👻 ⚠elt Set_eltfor bridge-generated list ALTREPs; R’s default raises an error.- altrep_
region_ ⚠buf - Create a mutable slice from an ALTREP
get_regionoutput buffer pointer. - altstring_
cache 🔒 ⚠ - Return a bridge string ALTREP’s data2 element cache, allocating it on first use.
- altstring_
cache_ 🔒 ⚠written - Whether R has stored a value into a string ALTREP’s cache.
- altstring_
cached_ 🔒 ⚠elt - Read cache slot
i, computing it from the Rust data on first use. - altstring_
dataptr 👻 ⚠ Dataptrfor bridge-generated string ALTREPs: fill every cache slot and return the cache’s pointer. A writable request marks the cache written first (seealtstring_cache_written), since R writes through it.- altstring_
elt 👻 ⚠ Eltfor bridge-generated string ALTREPs: each element is computed once.- altstring_
set_ 👻 ⚠elt Set_eltfor bridge-generated string ALTREPs; R’s default raises an error.- checked_
mkchar ⚠ - Create a CHARSXP from a Rust string, with checked length conversion.
- duplicate_
altrep_ 👻 ⚠data2 - Copy a bridge ALTREP’s data2 for a
Duplicatecallback. - duplicate_
altrep_ 👻 ⚠owner - Clone a derive-generated ALTREP owner while preserving its current R cache. R’s default DuplicateEX copies attributes and object flags after this hook.
- mark_
altstring_ 🔒 ⚠written - Mark a string ALTREP’s cache written; see
altstring_cache_written. - new_
altstring_ 🔒 ⚠cache - Allocate a string cache of length
nwith every slot empty (CNULL).