@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,
}

Seguir

@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

La red social del futuro: ¡Sin anuncios, sin vigilancia corporativa, diseño ético, y descentralización! ¡Sé dueño de tu información con Mastodon!