Space

Derive Macro Space 

Source
#[derive(Space)]
{
    // Attributes available to this derive:
    #[element]
}
Expand description

Derive relearn::spaces::Space for a struct as a Cartesian product space of its fields.

See ProductSpace to derive Space and all other basic space traits.

Each of the struct fields must also implement Space (when all generic params are bounded as Space).

If the struct has named fields then you must also specify #[element(ElementType)] where ElementType is the name of a struct with the same field names and types equal to the corresponding space element. The element type may also contain generics, like #[element(ElementType<T::Element>)].

ยงExamples

use relearn::spaces::{BooleanSpace, Space};

#[derive(Clone)]
struct MyElem<T> {
    first: bool,
    second: T,
}

#[derive(Space)]
#[element(MyElem<T::Element>)]
struct MySpace<T> {
    first: BooleanSpace,
    second: T,
}

For structs with unnamed fields, the element is always a tuple and #[element(...)] is ignored:

#[derive(Space)]
struct PairSpace(BooleanSpace, IndexSpace);