pub struct AsDataFrame<T: IntoDataFrame>(pub T);Expand description
Wrap a value and convert it to an R data.frame via IntoDataFrame when returned.
Use this at a call site to force a single return value into a data.frame without making
that the type’s default representation (for the always-a-data.frame default, use
#[derive(PreferDataFrame)] / #[miniextendr(dataframe)]). The inner T is typically a
Vec<Row> where Row derives DataFrameRow.
A failed conversion (DataFrameError) surfaces in R as
an error condition.
§Example
ⓘ
#[derive(DataFrameRow)]
struct Point { x: f64, y: f64 }
#[miniextendr]
fn grid() -> AsDataFrame<Vec<Point>> {
AsDataFrame(vec![Point { x: 0.0, y: 0.0 }, Point { x: 1.0, y: 1.0 }])
}
// In R: grid() returns a data.frame with columns x, yTuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone + IntoDataFrame> Clone for AsDataFrame<T>
impl<T: Clone + IntoDataFrame> Clone for AsDataFrame<T>
Source§fn clone(&self) -> AsDataFrame<T>
fn clone(&self) -> AsDataFrame<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug + IntoDataFrame> Debug for AsDataFrame<T>
impl<T: Debug + IntoDataFrame> Debug for AsDataFrame<T>
Source§impl<T: IntoDataFrame> From<T> for AsDataFrame<T>
impl<T: IntoDataFrame> From<T> for AsDataFrame<T>
Source§impl<T: IntoDataFrame> IntoR for AsDataFrame<T>
impl<T: IntoDataFrame> IntoR for AsDataFrame<T>
Source§type Error = DataFrameError
type Error = DataFrameError
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
Auto Trait Implementations§
impl<T> Freeze for AsDataFrame<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsDataFrame<T>where
T: RefUnwindSafe,
impl<T> Send for AsDataFrame<T>where
T: Send,
impl<T> Sync for AsDataFrame<T>where
T: Sync,
impl<T> Unpin for AsDataFrame<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsDataFrame<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AsDataFrame<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
🔬This is a nightly-only experimental API. (
core_io_internals)Returns a lower bound on the number of elements this container-like item
contains.
For example, an array
[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 = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)The largest safe length for a
[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.