Trait oso::ToPolarList
source · pub trait ToPolarList: Sealed {
// Required method
fn to_polar_list(self) -> Vec<PolarValue>
where Self: Sized;
}
Expand description
Convert tuples to Polar types.
This is a helper trait to convert Rust tuples (of types which implement ToPolar
) into a
Vec<PolarValue>
.
Examples
Empty tuple:
use oso::ToPolarList;
assert_eq!(().to_polar_list(), vec![]);
Mixed tuples:
use oso::{PolarValue, PolarClass, ToPolarList};
#[derive(PolarClass)]
struct MyClass;
let class = MyClass;
let string = "Hello, World!";
let number = 42;
let list = (class, string, number).to_polar_list();
assert_eq!(list.len(), 3);
assert!(matches!(list[0], PolarValue::Instance(_)));
assert_eq!(list[1], PolarValue::String(string.to_string()));
assert_eq!(list[2], PolarValue::Integer(number));
Required Methods§
sourcefn to_polar_list(self) -> Vec<PolarValue>where
Self: Sized,
fn to_polar_list(self) -> Vec<PolarValue>where
Self: Sized,
Convert these values into an array of Polar values.