|
26 | 26 | //! `T: Trait` bound to the corresponding trait. |
27 | 27 | //! |
28 | 28 | //! Multiple `derive_where` attributes can be added to an item, but only the |
29 | | -//! first one should use any path qualifications. Otherwise helper attributes |
30 | | -//! won't be applied to any but the first `derive_where` attribute on the item. |
| 29 | +//! first one must use any path qualifications. |
31 | 30 | //! |
32 | 31 | //! ``` |
33 | 32 | //! # use std::marker::PhantomData; |
34 | | -//! #[derive_where::derive_where(Clone, Debug; T)] |
35 | | -//! #[derive_where(PartialEq)] |
36 | | -//! struct Example1<T, U> { |
37 | | -//! a: u8, |
38 | | -//! #[derive_where(skip)] |
39 | | -//! b: u8, |
40 | | -//! ph: PhantomData<(T, U)>, |
41 | | -//! } |
42 | | -//! |
43 | | -//! let var1 = Example1 { |
44 | | -//! a: 42, |
45 | | -//! b: 42, |
46 | | -//! ph: PhantomData::<((), ())>, |
47 | | -//! }; |
48 | | -//! let var2 = Example1 { |
49 | | -//! a: 42, |
50 | | -//! b: 0, |
51 | | -//! ph: PhantomData::<((), ())>, |
52 | | -//! }; |
53 | | -//! |
54 | | -//! // Field `b` is not compared, as expected. |
55 | | -//! assert_eq!(var1, var2); |
56 | | -//! |
57 | | -//! #[derive_where::derive_where(Clone, Debug; T)] |
58 | | -//! #[derive_where::derive_where(PartialEq)] |
59 | | -//! struct Example2<T, U> { |
60 | | -//! a: u8, |
61 | | -//! #[derive_where(skip)] |
62 | | -//! b: u8, |
63 | | -//! ph: PhantomData<(T, U)>, |
64 | | -//! } |
65 | | -//! |
66 | | -//! let var1 = Example2 { |
67 | | -//! a: 42, |
68 | | -//! b: 42, |
69 | | -//! ph: PhantomData::<((), ())>, |
70 | | -//! }; |
71 | | -//! let var2 = Example2 { |
72 | | -//! a: 42, |
73 | | -//! b: 0, |
74 | | -//! ph: PhantomData::<((), ())>, |
75 | | -//! }; |
76 | | -//! |
77 | | -//! // Field `b` is compared! |
78 | | -//! assert_ne!(var1, var2); |
| 33 | +//! #[derive_where::derive_where(Clone)] |
| 34 | +//! #[derive_where(Debug)] |
| 35 | +//! struct Example1<T>(PhantomData<T>); |
79 | 36 | //! ``` |
80 | 37 | //! |
81 | 38 | //! In addition, the following convenience options are available: |
|
0 commit comments