pub struct AsDisplay<T>(pub T);Expand description
Wrap a T: Display and convert it to an R character scalar.
Any type implementing std::fmt::Display can be returned to R as a string
without implementing miniextendr traits.
§Example
ⓘ
use std::net::IpAddr;
#[miniextendr]
fn format_ip(ip: &str) -> AsDisplay<IpAddr> {
AsDisplay(ip.parse().unwrap())
}
// R gets: "192.168.1.1"Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Display> IntoR for AsDisplay<T>
impl<T: Display> IntoR for AsDisplay<T>
Source§type Error = Infallible
type Error = Infallible
The error type for fallible conversions. Read more
Source§fn try_into_sexp(self) -> Result<SEXP, Self::Error>
fn try_into_sexp(self) -> Result<SEXP, Self::Error>
Try to convert this value to an R SEXP. Read more
Source§unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>
unsafe fn try_into_sexp_unchecked(self) -> Result<SEXP, Self::Error>
Try to convert to SEXP without thread safety checks. Read more
impl<T: Copy> Copy for AsDisplay<T>
Auto Trait Implementations§
impl<T> Freeze for AsDisplay<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsDisplay<T>where
T: RefUnwindSafe,
impl<T> Send for AsDisplay<T>where
T: Send,
impl<T> Sync for AsDisplay<T>where
T: Sync,
impl<T> Unpin for AsDisplay<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsDisplay<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AsDisplay<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
Mutably borrows from an owned value. Read more