Via Andrei:
Another unrelated interesting thought is not having metadata wrapped in Option.
If the user does not want metadata, they can set S = ().
If they do want it always, they say S = Something.
If they do want it sometimes, they say S = Option<Something>.
#[derive(Debug, Clone)]
pub struct CSG<S: Clone> {
pub something: SomeStorage<S>,
pub metadata: S,
}
This may also lead to a neat solution that simplifies all the CSG constructor methods.
They could instead return CSG<()>, and CSG could for example have a method with_meta<SNew: Clone>(self, m: SNew) -> CSG<SNew> (or map_meta(...) etc.).
Then the workflow could be:
let a = CSG::sphere(...).with_meta(Color::BLUE);
let b = CSG::cylinder(...).with_meta(Color::RED);
let c = a.intersection(b);
Via Andrei:
Another unrelated interesting thought is not having metadata wrapped in
Option.If the user does not want metadata, they can set
S = ().If they do want it always, they say
S = Something.If they do want it sometimes, they say
S = Option<Something>.This may also lead to a neat solution that simplifies all the CSG constructor methods.
They could instead return
CSG<()>, andCSGcould for example have a methodwith_meta<SNew: Clone>(self, m: SNew) -> CSG<SNew>(ormap_meta(...)etc.).Then the workflow could be: