Skip to main content

IntoDataFrameSplit

Trait IntoDataFrameSplit 

Source
pub trait IntoDataFrameSplit: Sized {
    // Required method
    fn into_dataframe_split(self) -> DataFrameShape;
}
Expand description

Enum rows → variant-partitioned R data.frames. The split-representation sibling of IntoDataFrame.

Where IntoDataFrame produces one aligned data.frame (field-name union, NA fill for columns a variant doesn’t carry), this verb partitions the rows by variant: each partition is a data.frame with only that variant’s own columns (non-optional types — no NA fill from sibling variants), keyed by the snake_case variant name.

Implemented by #[derive(DataFrameRow)] on an enum row type (for Vec<Row>, via the hidden DataFrameRowSplit bridge below). Struct rows have no variants to partition, so the struct derive does not provide it. Call it on your data: rows.into_dataframe_split().

§Return shape

The returned DataFrameShape says which R value the split produced:

  • DataFrameShape::Bare — a single-variant enum: one data.frame.
  • DataFrameShape::PerVariantList — a multi-variant enum: one (snake_case_name, data.frame) entry per declared variant, in declaration order, which converts to a named R list of data.frames.

The derive never produces DataFrameShape::Split (that variant belongs to the serde result_to_dataframe helper). Variants absent from the input still appear as 0-row data.frames with that variant’s column shape; unit variants produce a 0-column data.frame with the correct row count. DataFrameShape is IntoR, so a #[miniextendr] function returns it directly.

§GC discipline (rooted by construction, #1750)

Every partition is an owned, GC-rooted BuiltDataFrame, so the result can be held across R allocations (building another frame, calling back into R) before it is returned or converted; there is no convert-immediately contract. The IntoR conversion assembles the named list and releases the per-partition roots.

Required Methods§

Source

fn into_dataframe_split(self) -> DataFrameShape

Partition the rows by variant into one data.frame per variant.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: DataFrameRowSplit> IntoDataFrameSplit for Vec<T>

Implementors§