Skip to main content

ToFlattened

Trait ToFlattened 

Source
pub trait ToFlattened {
    // Required method
    fn to_flattened<'a>(
        &'a self,
        arena: &'a Arena,
        table: &mut Table<'a>,
    ) -> Result<(), ToTomlError>;
}
Available on crate feature to-toml only.
Expand description

Trait for types that can be converted into flattened TOML table entries.

Used with #[toml(flatten)] on struct fields. Built-in implementations cover HashMap and BTreeMap.

If your type implements ToToml, use #[toml(flatten, with = flatten_any)] in your derive instead of implementing this trait. See helper::flatten_any.

Required Methods§

Source

fn to_flattened<'a>( &'a self, arena: &'a Arena, table: &mut Table<'a>, ) -> Result<(), ToTomlError>

Inserts this value’s entries directly into an existing table.

Each key-value pair is inserted into table rather than wrapping them in a nested sub-table.

Implementations on Foreign Types§

Source§

impl<K: ToToml, V: ToToml> ToFlattened for BTreeMap<K, V>

Source§

fn to_flattened<'a>( &'a self, arena: &'a Arena, table: &mut Table<'a>, ) -> Result<(), ToTomlError>

Source§

impl<K: ToToml, V: ToToml, H> ToFlattened for HashMap<K, V, H>

Source§

fn to_flattened<'a>( &'a self, arena: &'a Arena, table: &mut Table<'a>, ) -> Result<(), ToTomlError>

Implementors§