Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generic types #135

Merged
merged 12 commits into from
Jun 1, 2024
Merged

Support for generic types #135

merged 12 commits into from
Jun 1, 2024

Conversation

greyblake
Copy link
Owner

@greyblake greyblake commented May 31, 2024

This is still work in progress.
It's supposed to address #133 and #130

To do

  • Find a way to fix clippy warning using a reference to Cow is not recommended in
#[nutype(
    derive(Debug),
    validate(predicate = |s| s.len() >= 3),
)]
struct Clarabelle<'b>(Cow<'b, str>);
  • Use internally a very unique lifetime identifier, instead of 'a. E.g. Ensure that this works:
#[nutype(
    derive(Debug),
    validate(predicate = |s| s.len() >= 3),
)]
struct Clarabelle<'a>(Cow<'a, str>);
  • Make sure the example with Clarabelle can derive Display and other traits
  • Make it possible to set trait boundaries:
#[nutype(
    sanitize(with = |v| { v.sort(); v }),
    derive(Debug)
)]
struct SortedVec<T: Ord>(Vec<T>)

NOTE: this will be handled in a separate story: #142

@greyblake greyblake self-assigned this Jun 1, 2024
@greyblake greyblake merged commit 0f79e72 into master Jun 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant