johnstonskj / rust-email_address

A Rust crate providing an implementation of an RFC-compliant `EmailAddress` newtype.
MIT License
62 stars 11 forks source link

Removing `Eq` on `struct EmailTrait` in 0.2.6 was a API breaking change. #29

Closed dpc closed 1 month ago

dpc commented 1 month ago

Downstream deps are failing to build.

raif-s-naffah commented 1 month ago

+ 1.

same occurs when using EmailAddress as an unnamed field of a struct (i.e. to customize serde serialization/deserialization).

#[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)]
pub(crate) struct InnerEmailAddress(
    #[serde(serialize_with = "mbox_ser", deserialize_with = "mbox_des")] EmailAddress,
);

for completness sake, here's the compiler diagnostic message:

error[E0277]: the trait bound `EmailAddress: std::cmp::Eq` is not satisfied
   --> .../src/email_address.rs:16:74
    |
14  | #[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)]
    |                        -- in this derive macro expansion
15  | pub(crate) struct InnerEmailAddress(
16  |     #[serde(serialize_with = "mbox_ser", deserialize_with = "mbox_des")] EmailAddress,
    |                                                                          ^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `EmailAddress`
    |
note: required by a bound in `AssertParamIsEq`
   --> /opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:360:31
    |
360 | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               ^^ required by this bound in `AssertParamIsEq`
    = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
KisaragiEffective commented 1 month ago

also +1: https://github.com/KisaragiEffective/reinventory-manager/pull/439

RemiBardon commented 1 month ago

+1

Why was it removed in the first place? (see the problematic diff in https://github.com/johnstonskj/rust-email_address/commit/eadd524d460b893e778e4895d0c97b989aa687dd#r144641022)

alexipeck commented 1 month ago

I'm dealing with problems from this also, why was it removed?

I use it within a HashMap (HashMap<EmailAddress, Uuid>)

error[E0277]: the trait bound `EmailAddress: std::cmp::Eq` is not satisfied
    --> src/auth_manager.rs:214:28
     |
214  |                 .collect::<HashMap<EmailAddress, Uuid>>(),
     |                  -------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `EmailAddress`, which is required by `HashMap<EmailAddress, Uuid>: FromIterator<(EmailAddress, Uuid)>`
     |                  |
     |                  required by a bound introduced by this call
     |
     = help: the trait `FromIterator<(K, V)>` is implemented for `HashMap<K, V, S>`
     = note: required for `HashMap<EmailAddress, Uuid>` to implement `FromIterator<(EmailAddress, Uuid)>`
note: required by a bound in `collect`
    --> /home/me/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1999:19
     |
1999 |     fn collect<B: FromIterator<Self::Item>>(self) -> B
     |                   ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
johnstonskj commented 1 month ago

Fixed in 0.2.8