prae
prae copied to clipboard
prae is a crate that aims to provide a better way to define types that require validation.
Not sure if it's possible. It should look something like this: ```rust prae::define! { pub NonEmptyVec: Vec; ensure |v| !v.is_empty(); } ```
Example for structs: ```rust define! { pub User: struct { pub name: String, } ensure |u| !u.name.is_empty() } ``` Example for enums: ```rust define! { pub Error: enum { WithMessage(String),...
https://github.com/teenjuna/prae/blob/bd2bfd476108ebcfcb91c2710fdf92eb123a169d/prae/src/lib.rs#L695-L700
I noticed that the current implementation of `define!` and `extend!` macros are incompatible with `rustfmt`. Therefore, I propose the following new design: ```rust define!({ #[derive(Debug)] pub struct Text(String); adjust(|t| *t...
Right now, when value fails validation by `ensure` closure, the returned error is a static string `"value is invalid"`. It would be cool to support customisation of that string: ```rust...
Right now README file is generated using [`cargo-readme`](https://github.com/livioribeiro/cargo-readme), but this tool doesn't support intralinks and wasn't maintained for more than 2 years. [Link to `cargo-rdme`](https://crates.io/crates/cargo-rdme)