@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.

Regístrate para participar en la conversación
MaSToDoN.MX

Mastodon es una red social basada en protocolos web abiertos y software libre y de código abierto. Está descentralizado como correo electrónico.