Nutype 0.4.0 released!

Release notes: Release Nutype 0.4.0 · greyblake/nutype · GitHub

Nutype is a Rust crate featuring a procedural macro designed to enhance the regular newtype pattern with additional capabilities such as sanitization and validation. This enhancement ensures that values can only be instantiated after successfully passing predefined checks.

Example 1:
Ensure that Hour type hold value that lays in the 0..=23 range:

        greater_or_equal = 0,
        less_or_equal = 23,
pub struct Hour(u8);

Example 2:
Ensure that GuestList is never empty and its values are alphabetically sorted:

    derive(Debug, PartialEq, Deref, AsRef),
    sanitize(with = |mut guests| { guests.sort(); guests }),
    validate(predicate = |guests| !guests.is_empty() ),
pub struct GuestList(Vec<String>);

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.