Expand description
String conversions — STRSXP requires special handling via STRING_ELT.
R stores strings as STRSXP (vector of CHARSXP). Each element requires
STRING_ELT + R_CHAR to extract, unlike numeric vectors which expose
a contiguous data pointer.
Covers: &str, String, char, Option<&str>, Option<String>,
Vec<String>, Vec<&str>, Box<[String]>.
§Tradeoff
Prefer borrowed &str / Vec<&str> over owned String / Vec<String>
when the data only needs to live for the .Call — borrowed strings point
straight into R’s CHARSXP pool with no allocation. Use Option<String>
/ Vec<Option<String>> when callers may pass NA_character_; the plain
String / Vec<String> impls map NA to "", which is lossy. The optional
forms preserve the distinction as None.
UTF-8/ASCII strings use a zero-copy fast path. Other text encodings are
translated to UTF-8; an R string marked as bytes, or one that is not
valid UTF-8, is refused with an SexpError::InvalidValue (an argument
error in R: 'x' must be a single string: marked as bytes, not text). Outbound
counterparts: String / &str impls in crate::into_r.
Re-exports§
use crate::SEXP;🔒use crate::from_r::SexpError;🔒use crate::from_r::TryFromSexp;🔒use crate::from_r::is_null_or_plain_na;🔒use crate::from_r::is_null_or_plain_na_unchecked;🔒use crate::from_r::scalar_charsxp;🔒use crate::from_r::scalar_charsxp_unchecked;🔒use crate::from_r::try_charsxp_to_str;🔒use crate::from_r::try_charsxp_to_str_unchecked;🔒use std::rc::Rc;🔒use std::sync::Arc;🔒