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

Relax the rules around derive #191

Open
musjj opened this issue Oct 23, 2024 · 1 comment
Open

Relax the rules around derive #191

musjj opened this issue Oct 23, 2024 · 1 comment

Comments

@musjj
Copy link

musjj commented Oct 23, 2024

It looks like that nutype has its own special derive() implementation and it can really get in the way sometimes. For example, I want to use the sqlx::Type derive, but I can't:

#[nutype(
    validate(not_empty, len_char_max = 20),
    derive(sqlx::Type), // #[nutype] does not know how to derive `sqlx` trait.
    sqlx(transparent)
)]
pub struct Name(String);

There's also issues regarding conditional derives: #188

Would it be possible to relax the rule and just let the user use derive directly on the type?

@greyblake
Copy link
Owner

Hi, thanks for reporting the problem.
Nutype takes a full control over derive(..) to ensure that it's not possible to derive traits that possibly can mutate value avoiding the constraints. E.g. deriving DerefMut would make a problem.

I have plans to have in-house support for Diesel and SQLx.

Would it be possible to relax the rule and just let the user use derive directly on the type?
Also I have plan to add a feature like unsafe-derive, which would allow users to derive whatever they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants