Skip to content

Rework metadata #31

@timschmidt

Description

@timschmidt

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions