greyblake / nutype

Rust newtype with guarantees 🇺🇦 🦀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BREAKING] Remove derive(*)

greyblake opened this issue · comments

It was controversial experiment from the very beginning.
At this point we want to get rid of it.

See also:
https://www.reddit.com/r/rust/comments/14j7w46/comment/jpzag6f/?utm_source=reddit&utm_medium=web2x&context=3

Context

At the moment in version 0.3.1 it's possible to derive traits with #[derive(*)], where * means traits that make sense "by default".

You can find those traits be search for fn unfold_asterisk_traits in the code.

Spec

  • In crate nutype_macros
  • Remove code related to parsing * in derive and the logic that unfolds it.
  • Generate a friendly message at compile time, saying that #[derive(*)] is no longer possible.
  • Adjust all the tests that are necessary (run all tests with make test)
  • Add a note in the CHANGELOG about the breaking change

Acceptance Criteria

I have the following code:

#[nutype()]
#[derive(*)]
pub struct Name(String);

It does not compile. Th error message points to

#[derive(*)]
         ^

The same applies if the inner type is integer of float.

Addressed in #60