greyblake / nutype

Rust newtype with guarantees πŸ‡ΊπŸ‡¦ πŸ¦€
MIT License
1.42k stars 23 forks source link

derive(AsRef) with generic boundaries is not compiling #156

Closed greyblake closed 4 months ago

greyblake commented 4 months ago

The following should work:

#[nutype(
    sanitize(with = |mut v| { v.sort(); v }),
    validate(predicate = |vec| !vec.is_empty()),
    derive(Debug, PartialEq, AsRef),
)]
struct SortedNotEmptyVec<T: Ord>(Vec<T>);
greyblake commented 4 months ago

Fixed in https://github.com/greyblake/nutype/pull/158