-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
If updating to newer rust-mos, the current const traits are no longer supported. Compile time conversions and construction are available in nightly Rust, only. When available in stable, go over existing classes to minimize runtime computation. Ping @sbechet
// Tested with Nightly 1.91 (Aug. 2025)
#![feature(const_trait_impl)]
#![feature(const_from)]
#![feature(const_default)]
#![feature(derive_const)]
#[derive_const(Default)]
struct Byte(u8);
impl const From<u8> for Byte {
fn from(a: u8) -> Self {
Self(a)
}
}
fn main() {
const DEFAULT_BYTE: Byte = Byte::default();
const BYTE: Byte = Byte::from(2);
println!("{}", DEFAULT_BYTE.0);
println!("{}", BYTE.0);
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request