pub struct AsFromStr<T>(pub T);Expand description
Wrap a parsed T: FromStr from an R character scalar.
Pass an R character scalar and it will be parsed into T via str::parse().
NA_character_ is refused with SexpError::Na
rather than parsed as "". A parse failure quotes the value:
"not-an-ip": invalid IP address syntax.
For numbers read like R’s as.numeric() (from character, factor labels, or
numbers, with NA as None), use AsNumeric instead.
§Example
use std::net::IpAddr;
#[miniextendr]
fn check_ip(addr: AsFromStr<IpAddr>) -> bool {
addr.0.is_loopback()
}
// R: check_ip("127.0.0.1") → TRUETuple Fields§
§0: TTrait Implementations§
Source§impl<T: Display> IntoR for AsFromStr<T>
The value’s Display text as a character scalar, which the marker parses
back. A trait’s View passes an AsFromStr argument this way, so the value
crosses unchanged when T::from_str(&t.to_string()) == t (the std
numbers, IpAddr, Uuid, …). This IntoR exists for the trait ABI; to
return text from a function, use AsDisplay.
impl<T: Display> IntoR for AsFromStr<T>
The value’s Display text as a character scalar, which the marker parses
back. A trait’s View passes an AsFromStr argument this way, so the value
crosses unchanged when T::from_str(&t.to_string()) == t (the std
numbers, IpAddr, Uuid, …). This IntoR exists for the trait ABI; to
return text from a function, use AsDisplay.
Source§fn try_into_sexp(self) -> Result<SEXP, Self::Error>
fn try_into_sexp(self) -> Result<SEXP, Self::Error>
Source§unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>
unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>
Source§unsafe fn into_sexp_unchecked(self) -> SEXP
unsafe fn into_sexp_unchecked(self) -> SEXP
Source§impl<T: FromStr> TryFromSexp for AsFromStr<T>
impl<T: FromStr> TryFromSexp for AsFromStr<T>
Source§const CHARACTER_ONLY: bool = true
const CHARACTER_ONLY: bool = true
NULL, is a character vector or a factor. Read moreSource§fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
fn try_from_sexp(sexp: SEXP) -> Result<Self, Self::Error>
Source§const NATIVE_BORROW: Option<NativeBorrow> = None
const NATIVE_BORROW: Option<NativeBorrow> = None
Source§#[doc(hidden)]const __MX_EXPECTATION: Option<&'static str> = None
#[doc(hidden)]const __MX_EXPECTATION: Option<&'static str> = None
#[miniextendr] cannot tell from the type as written: the
<expected> of a failed conversion’s '<p>' must be <expected>: .... Read moreSource§unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>
unsafe fn try_from_sexp_unchecked(sexp: SEXP) -> Result<Self, Self::Error>
Source§#[doc(hidden)]unsafe fn __mx_try_from_rooted(root: Root<'_>) -> Result<Self, Self::Error>
#[doc(hidden)]unsafe fn __mx_try_from_rooted(root: Root<'_>) -> Result<Self, Self::Error>
Source§#[doc(hidden)]fn __mx_has_na(&self) -> bool
#[doc(hidden)]fn __mx_has_na(&self) -> bool
#[miniextendr(no_na)]
refuses after the conversion. Read moreSource§#[doc(hidden)]fn __mx_input_has_na(&self, input: SEXP) -> bool
#[doc(hidden)]fn __mx_input_has_na(&self, input: SEXP) -> bool
#[miniextendr(no_na)] refuses this converted argument, read
from input (the R value it converted from), when no R guard ran. Read moreSource§#[doc(hidden)]fn __mx_try_from_sexp_with_check(
sexp: SEXP,
check: &ElementCheck<'_>,
) -> Result<Self, SexpError>
#[doc(hidden)]fn __mx_try_from_sexp_with_check(
sexp: SEXP,
check: &ElementCheck<'_>,
) -> Result<Self, SexpError>
check, an element type’s
TryFromSexpElement::check_sexp,
on the R value that carries an element’s class (#1837). Read moreSource§#[doc(hidden)]unsafe fn __mx_try_from_sexp_unchecked_with_check(
sexp: SEXP,
check: &ElementCheck<'_>,
) -> Result<Self, SexpError>
#[doc(hidden)]unsafe fn __mx_try_from_sexp_unchecked_with_check(
sexp: SEXP,
check: &ElementCheck<'_>,
) -> Result<Self, SexpError>
Auto Trait Implementations§
impl<T> Freeze for AsFromStr<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsFromStr<T>where
T: RefUnwindSafe,
impl<T> Send for AsFromStr<T>where
T: Send,
impl<T> Sync for AsFromStr<T>where
T: Sync,
impl<T> Unpin for AsFromStr<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsFromStr<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AsFromStr<T>where
T: 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConsumingFallible for Twhere
T: Clone,
Source§impl<T> RDebug for Twhere
T: Debug,
impl<T> RDebug for Twhere
T: Debug,
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.