pub struct StrVecBuilder<'a> {
vec: SEXP,
_scope: &'a ProtectScope,
}Expand description
Builder for constructing string vectors with efficient protection management.
§Example
unsafe fn build_strvec(strings: &[&str]) -> SEXP {
let scope = ProtectScope::new();
let builder = StrVecBuilder::new(&scope, strings.len() as isize);
for (i, s) in strings.iter().enumerate() {
builder.set_str(i as isize, s);
}
builder.into_sexp()
}Fields§
§vec: SEXP§_scope: &'a ProtectScopeImplementations§
Source§impl<'a> StrVecBuilder<'a>
impl<'a> StrVecBuilder<'a>
Sourcepub unsafe fn new(scope: &'a ProtectScope, len: usize) -> Self
pub unsafe fn new(scope: &'a ProtectScope, len: usize) -> Self
Create a new string vector builder with the given length.
§Safety
Must be called from the R main thread.
Sourcepub unsafe fn new_unchecked(scope: &'a ProtectScope, len: usize) -> Self
pub unsafe fn new_unchecked(scope: &'a ProtectScope, len: usize) -> Self
Create a new string vector builder via the unchecked FFI allocation path.
_unchecked twin of new: the STRSXP is allocated with
Rf_allocVector_unchecked (see ProtectScope::alloc_character_unchecked),
bypassing the main-thread assertion. Use inside ALTREP callbacks,
with_r_unwind_protect, or with_r_thread bodies, and pair element
insertion with the _unchecked string-element setters.
§Safety
Must be called from the R main thread, in a context where the checked-FFI assertion is intentionally bypassed (see CLAUDE.md “FFI thread checking”).
Sourcepub unsafe fn set_opt_str(&self, idx: isize, s: Option<&str>)
pub unsafe fn set_opt_str(&self, idx: isize, s: Option<&str>)
Sourcepub fn into_strvec(self) -> StrVec<'a>
pub fn into_strvec(self) -> StrVec<'a>
Convert to a StrVec view, leashed to the builder’s protect scope 'a.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for StrVecBuilder<'a>
impl<'a> !Send for StrVecBuilder<'a>
impl<'a> !Sync for StrVecBuilder<'a>
impl<'a> !UnwindSafe for StrVecBuilder<'a>
impl<'a> Freeze for StrVecBuilder<'a>
impl<'a> Unpin for StrVecBuilder<'a>
impl<'a> UnsafeUnpin for StrVecBuilder<'a>
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: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes