StructToVec

Trait StructToVec 

Source
pub trait StructToVec<Item>: Sized + StructToArray<Item>
where Item: Clone,
{ // Required methods fn to_vec(self) -> Vec<Item>; fn from_vec(v: &[Item]) -> Self; }
Expand description

Extension trait for converting between structs and Vec<Item>.

This trait is automatically implemented for any type that implements StructToArray<Item> where Item: Clone.

Required Methods§

Source

fn to_vec(self) -> Vec<Item>

Converts the struct into a Vec of its fields.

Source

fn from_vec(v: &[Item]) -> Self

Creates a struct from a slice of field values.

§Panics

Panics if the slice length does not match the number of fields in the struct.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, Item> StructToVec<Item> for S
where S: StructToArray<Item>, Item: Clone,