pub struct IterStringData<I>{
state: IterState<I, String>,
}Expand description
Iterator-backed string vector.
Wraps an iterator producing String values and exposes it as an ALTREP character vector.
§Performance Warning
Unlike other Iter*Data types, accessing ANY element forces full materialization
of the entire iterator. This is because R’s AltStringData::elt() returns a borrowed
&str, which requires stable storage. The internal RefCell cannot provide the required
lifetime, so all strings must be materialized upfront.
This means:
elt(0)on a million-element iterator will generate ALL million strings- There is no lazy evaluation benefit for string iterators
- Memory usage equals the full vector regardless of access patterns
For truly lazy string ALTREP, consider implementing a custom type that stores strings in a way that allows borrowing without full materialization (e.g., arena allocation or caching generated strings incrementally).
§Example
ⓘ
use miniextendr_api::altrep_data::IterStringData;
let iter = (0..5).map(|x| format!("item_{}", x));
let data = IterStringData::from_iter(iter, 5);
// First access to ANY element will materialize all 5 stringsFields§
§state: IterState<I, String>Implementations§
Source§impl<I> IterStringData<I>
impl<I> IterStringData<I>
Source§impl<I> IterStringData<I>where
I: ExactSizeIterator<Item = String>,
impl<I> IterStringData<I>where
I: ExactSizeIterator<Item = String>,
Sourcepub fn from_exact_iter(iter: I) -> Self
pub fn from_exact_iter(iter: I) -> Self
Create from an ExactSizeIterator (length auto-detected).
Trait Implementations§
Source§impl<I: Iterator<Item = String> + 'static> AltString for IterStringData<I>
impl<I: Iterator<Item = String> + 'static> AltString for IterStringData<I>
Source§impl<I> AltStringData for IterStringData<I>
impl<I> AltStringData for IterStringData<I>
Source§impl<I: Iterator<Item = String> + 'static> AltVec for IterStringData<I>
impl<I: Iterator<Item = String> + 'static> AltVec for IterStringData<I>
Source§const HAS_DATAPTR: bool = false
const HAS_DATAPTR: bool = false
Set to
true to register dataptr.Source§const HAS_DATAPTR_OR_NULL: bool = false
const HAS_DATAPTR_OR_NULL: bool = false
Set to
true to register dataptr_or_null.Source§fn dataptr_or_null(_x: SEXP) -> *const c_void
fn dataptr_or_null(_x: SEXP) -> *const c_void
Get data pointer without forcing materialization.
Source§const HAS_EXTRACT_SUBSET: bool = false
const HAS_EXTRACT_SUBSET: bool = false
Set to
true to register extract_subset.Source§impl<I: Iterator<Item = String> + 'static> Altrep for IterStringData<I>
impl<I: Iterator<Item = String> + 'static> Altrep for IterStringData<I>
Source§const GUARD: AltrepGuard = crate::altrep_traits::AltrepGuard::RUnwind
const GUARD: AltrepGuard = crate::altrep_traits::AltrepGuard::RUnwind
The guard mode for all ALTREP trampolines on this type. Read more
Source§fn length(x: SEXP) -> R_xlen_t
fn length(x: SEXP) -> R_xlen_t
Returns the length of the ALTREP vector.
This is REQUIRED - R cannot determine vector length without it.
Source§const HAS_SERIALIZED_STATE: bool = false
const HAS_SERIALIZED_STATE: bool = false
Set to
true to register serialized_state.Source§fn serialized_state(_x: SEXP) -> SEXP
fn serialized_state(_x: SEXP) -> SEXP
Return serialization state.
Source§const HAS_UNSERIALIZE: bool = false
const HAS_UNSERIALIZE: bool = false
Set to
true to register unserialize.Source§const HAS_UNSERIALIZE_EX: bool = false
const HAS_UNSERIALIZE_EX: bool = false
Set to
true to register unserialize_ex.Source§fn unserialize_ex(
_class: SEXP,
_state: SEXP,
_attr: SEXP,
_objf: i32,
_levs: i32,
) -> SEXP
fn unserialize_ex( _class: SEXP, _state: SEXP, _attr: SEXP, _objf: i32, _levs: i32, ) -> SEXP
Extended unserialization with attributes.
Source§const HAS_DUPLICATE: bool = false
const HAS_DUPLICATE: bool = false
Set to
true to register duplicate.Source§const HAS_DUPLICATE_EX: bool = false
const HAS_DUPLICATE_EX: bool = false
Set to
true to register duplicate_ex.Source§const HAS_COERCE: bool = false
const HAS_COERCE: bool = false
Set to
true to register coerce.Source§const HAS_INSPECT: bool = false
const HAS_INSPECT: bool = false
Set to
true to register inspect.Source§impl<I> AltrepLen for IterStringData<I>
impl<I> AltrepLen for IterStringData<I>
Source§impl<I: Iterator<Item = String> + 'static> InferBase for IterStringData<I>
impl<I: Iterator<Item = String> + 'static> InferBase for IterStringData<I>
Source§unsafe fn make_class(
class_name: *const i8,
pkg_name: *const i8,
) -> R_altrep_class_t
unsafe fn make_class( class_name: *const i8, pkg_name: *const i8, ) -> R_altrep_class_t
Create the ALTREP class handle. Read more
Source§unsafe fn install_methods(cls: R_altrep_class_t)
unsafe fn install_methods(cls: R_altrep_class_t)
Install ALTREP methods on the class. Read more
Source§impl<I: Iterator<Item = String> + 'static> TypedExternal for IterStringData<I>
impl<I: Iterator<Item = String> + 'static> TypedExternal for IterStringData<I>
Source§const TYPE_NAME: &'static str = "IterStringData"
const TYPE_NAME: &'static str = "IterStringData"
The type name as a static string (for debugging and display)
Source§const TYPE_NAME_CSTR: &'static [u8] = b"IterStringData\0"
const TYPE_NAME_CSTR: &'static [u8] = b"IterStringData\0"
The type name as a null-terminated C string (for R tag display)
Source§const TYPE_ID_CSTR: &'static [u8] = b"miniextendr_api::altrep::IterStringData\0"
const TYPE_ID_CSTR: &'static [u8] = b"miniextendr_api::altrep::IterStringData\0"
Namespaced type ID as a null-terminated C string (for type checking). Read more
Auto Trait Implementations§
impl<I> !Freeze for IterStringData<I>
impl<I> !RefUnwindSafe for IterStringData<I>
impl<I> Send for IterStringData<I>where
I: Send,
impl<I> !Sync for IterStringData<I>
impl<I> Unpin for IterStringData<I>where
I: Unpin,
impl<I> UnsafeUnpin for IterStringData<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for IterStringData<I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> AltrepExtract for Twhere
T: TypedExternal,
impl<T> AltrepExtract for Twhere
T: TypedExternal,
Source§unsafe fn altrep_extract_ref(x: SEXP) -> &'static T
unsafe fn altrep_extract_ref(x: SEXP) -> &'static T
Extract a shared reference from the ALTREP data1 slot. Read more
Source§unsafe fn altrep_extract_mut(x: SEXP) -> &'static mut T
unsafe fn altrep_extract_mut(x: SEXP) -> &'static mut T
Extract a mutable reference from the ALTREP data1 slot. Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more