Skip to main content

RCoerceList

Trait RCoerceList 

Source
pub trait RCoerceList {
    // Required method
    fn as_list(&self) -> Result<List, RCoerceError>;
}
Expand description

Trait for types that can be coerced to list via as.list().

§Example

impl RCoerceList for MyStruct {
    fn as_list(&self) -> Result<List, RCoerceError> {
        Ok(List::from_pairs(vec![
            ("field1", self.field1.clone()),
            ("field2", self.field2.clone()),
        ]))
    }
}

Required Methods§

Source

fn as_list(&self) -> Result<List, RCoerceError>

Convert to an R list.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§