nutype
nutype copied to clipboard
Respect `where` clause in generic newtypes
At the moment boundaries can be set only within <T: ..>, it's not possible to set boundaries with where clause.
One particular usecase where it would be helpful is this one:
#[nutype(
validate(predicate = |c| c.into_iter().next().is_some()),
)]
struct NonEmpty<C>(C)
where
for<'a> &'a C: IntoIterator;
This would allow to define NonEmpty collection, regardless of what kind of collection it is.
See also https://github.com/greyblake/nutype/issues/130#issuecomment-2212415460