Follow

@federicomena now you're one step away from using a proper const generic for this :)

enum Orientation {
Horizontal,
Vertical,
Both
}

pub struct Length<const orientation: Orientation> {
pub length: f64,
pub unit: LengthUnit,
}

@bugaevc One thing I haven't looked at is the generated code. Presumably the compiler inlines the Orientation implementations into the monomorphized functions, but then again those are mostly identical. A memory/CPU tradeoff, I guess.

Sign in to participate in the conversation
Mastodon for Tech Folks

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!