Skip to main content

SoaToOwned

Trait SoaToOwned 

Source
pub trait SoaToOwned<T>: AsSoaRef {
    // Required method
    fn soa_to_owned(&self) -> T;
}
Expand description

Analogous to clone or to_owned, but for SoA array elements.

The opposite of SoaClone.

Required Methods§

Source

fn soa_to_owned(&self) -> T

Construct an owned value from an SoA element.

§Example
#[derive(Soars, SoaClone, Debug, PartialEq, Clone)]
#[soa_derive(Debug)]
struct Point(f32, f32);

let soa = soa![Point(1.0, 2.0), Point(3.0, 4.0)];
let el = soa.idx(1);
let owned = el.soa_to_owned();
assert_eq!(owned, Point(3.0, 4.0));

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<S, D> SoaToOwned<D> for S
where S: AsSoaRef<Item = D>, D: SoaClone,

Reflexive auto-implementation. Whenever SoaClone is implemented, so to is this one going in the opposite direction. This is analogous to the relationship between From and Into.