pub struct IterStringData<I>{
state: IterState<I, String>,
}Expand description
Iterator-backed string vector data adaptor.
Wraps an iterator producing String values and implements the data-level
traits (AltrepLen + AltStringData) for backing an ALTREP character
vector. To expose it to R, wrap it in a #[derive(AltrepString)] +
#[altrep(manual)] struct (see the module docs).
§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> AltStringData for IterStringData<I>
impl<I> AltStringData for IterStringData<I>
Auto Trait Implementations§
impl<I> !Freeze for IterStringData<I>
impl<I> !RefUnwindSafe for IterStringData<I>
impl<I> !Sync for IterStringData<I>
impl<I> Send for IterStringData<I>where
I: Send,
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> 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
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.