Skip to main content

charsxp_to_str

Function charsxp_to_str 

Source
pub(crate) unsafe fn charsxp_to_str(charsxp: SEXP) -> &'static str
Expand description

Convert CHARSXP to &str — zero-copy from R’s string data.

Uses R_CHAR + LENGTH (O(1), no strlen). UTF-8 validity is guaranteed by miniextendr_assert_utf8_locale() at package init, so no per-string validation is needed.

§Safety

  • charsxp must be a valid CHARSXP (not NA_STRING, not null).
  • The returned &str is only valid as long as R doesn’t GC the CHARSXP.