Is there a way at compile-time to ensure non-zero Strings or collections?
For instance, I know I can enforce a precise length with:
struct Me {
name: [char;13]
}
But could I do something like this?:
struct Me<T: GREATER_THAN<1>> {
name: [char;T]
}
This would save from a lot of runtime checks on string length (e.g. in a new
or build
validator)
I mean... if I could I'd use hypothetical higher-kinded types like this:
struct Me {
name: NonEmpty<String>, // compile error if you write "".into()
friends: NonEmpty<Vec<String>>
}
This looks kind related...: GitHub - Boddlnagg/tylar: Type-Level Arithmetic in Rust