You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-34Lines changed: 50 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,8 @@ custom generic type bounds.
11
11
12
12
## Usage
13
13
14
-
The `derive_where` attribute can be used just like std's `#[derive(...)]`
15
-
statements:
14
+
The [`derive_where`] attribute can be used just like
15
+
std's `#[derive(...)]`statements:
16
16
17
17
```rust
18
18
#[derive_where(Clone, Debug)]
@@ -23,8 +23,8 @@ This will generate trait implementations for `Example` for any `T`,
23
23
as opposed to std's derives, which would only implement these traits with
24
24
`T: Trait` bound to the corresponding trait.
25
25
26
-
Multiple `derive_where` attributes can be added to an item, but only the
27
-
first one must use any path qualifications.
26
+
Multiple [`derive_where`] attributes can be added to an
27
+
item, but only the first one must use any path qualifications.
28
28
29
29
```rust
30
30
#[derive_where::derive_where(Clone, Debug)]
@@ -109,8 +109,8 @@ enum Example<T> {
109
109
### Skipping fields
110
110
111
111
With a `skip` or `skip_inner` attribute fields can be skipped for traits
112
-
that allow it, which are: [`Debug`], [`Hash`], [`Ord`](https://doc.rust-lang.org/core/cmp/trait.Ord.html), [`PartialOrd`](https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html),
113
-
[`PartialEq`](https://doc.rust-lang.org/core/cmp/trait.PartialEq.html), [`Zeroize`] and [`ZeroizeOnDrop`].
112
+
that allow it, which are: [`Debug`], [`Hash`], [`Ord`], [`PartialOrd`],
113
+
[`PartialEq`], [`Zeroize`] and [`ZeroizeOnDrop`].
114
114
115
115
```rust
116
116
#[derive_where(Debug, PartialEq; T)]
@@ -164,12 +164,12 @@ assert_ne!(
164
164
165
165
### `Zeroize` options
166
166
167
-
[`Zeroize`] has two options:
168
-
-`crate`: an item-level option which specifies a path to the `zeroize`
167
+
`Zeroize` has two options:
168
+
-`crate`: an item-level option which specifies a path to the [`zeroize`]
169
169
crate in case of a re-export or rename.
170
-
-`fqs`: a field-level option which will use fully-qualified-syntax instead
171
-
of calling the [`zeroize`][`method@zeroize`] method on `self` directly.
172
-
This is to avoid ambiguity between another method also called `zeroize`.
170
+
-`fqs`: a field-level option which will use fully-qualified-syntax instead
171
+
of calling the [`zeroize`][method@zeroize] method on `self` directly. This
172
+
is to avoid ambiguity between another method also called `zeroize`.
173
173
174
174
```rust
175
175
#[derive_where(Zeroize(crate="zeroize_"))]
@@ -198,10 +198,10 @@ assert_eq!(test.0, 0);
198
198
199
199
If the `zeroize-on-drop` feature is enabled, it implements [`ZeroizeOnDrop`]
200
200
and can be implemented without [`Zeroize`], otherwise it only implements
201
-
[`Drop`](https://doc.rust-lang.org/core/ops/trait.Drop.html) and requires [`Zeroize`] to be implemented.
201
+
[`Drop`] and requires [`Zeroize`] to be implemented.
202
202
203
203
[`ZeroizeOnDrop`] has one option:
204
-
-`crate`: an item-level option which specifies a path to the `zeroize`
204
+
-`crate`: an item-level option which specifies a path to the [`zeroize`]
-[`Zeroize`]: Only available with the `zeroize` crate feature.
227
227
-[`ZeroizeOnDrop`]: Only available with the `zeroize` crate feature. If the
228
228
`zeroize-on-drop` feature is enabled, it implements [`ZeroizeOnDrop`],
229
-
otherwise it only implements [`Drop`](https://doc.rust-lang.org/core/ops/trait.Drop.html).
229
+
otherwise it only implements [`Drop`].
230
230
231
231
### Supported items
232
232
@@ -235,27 +235,28 @@ it's best to discourage usage that could be covered by std's `derive`. For
235
235
example unit structs and enums only containing unit variants aren't
236
236
supported.
237
237
238
-
Unions only support [`Clone`](https://doc.rust-lang.org/core/clone/trait.Clone.html) and [`Copy`](https://doc.rust-lang.org/core/marker/trait.Copy.html).
238
+
Unions only support [`Clone`] and [`Copy`].
239
239
240
240
### `no_std` support
241
241
242
242
`no_std` support is provided by default.
243
243
244
244
## Crate features
245
245
246
-
-`nightly`: Implements [`Ord`](https://doc.rust-lang.org/core/cmp/trait.Ord.html) and [`PartialOrd`](https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html) with the help of
247
-
[`core::intrinsics::discriminant_value`](https://doc.rust-lang.org/core/intrinsics/fn.discriminant_value.html), which is what Rust does by
248
-
default too. Without this feature [`transmute`](https://doc.rust-lang.org/core/mem/fn.transmute.html) is
249
-
used to convert [`Discriminant`](https://doc.rust-lang.org/core/mem/struct.Discriminant.html) to a [`i32`](https://doc.rust-lang.org/core/primitive.i32.html),
246
+
-`nightly`: Implements [`Ord`] and [`PartialOrd`] with the help of
247
+
[`core::intrinsics::discriminant_value`], which is what Rust does by
248
+
default too. Without this feature [`transmute`] is
249
+
used to convert [`Discriminant`] to a [`i32`],
250
250
which is the underlying type.
251
-
-`safe`: Implements [`Ord`](https://doc.rust-lang.org/core/cmp/trait.Ord.html) and [`PartialOrd`](https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html) manually. This is much
251
+
-`safe`: Implements [`Ord`] and [`PartialOrd`] manually. This is much
252
252
slower, but might be preferred if you don't trust derive-where. It also
253
-
replaces all cases of [`core::hint::unreachable_unchecked`](https://doc.rust-lang.org/core/hint/fn.unreachable_unchecked.html) in [`Ord`](https://doc.rust-lang.org/core/hint/fn.unreachable_unchecked.html),
254
-
[`PartialEq`](https://doc.rust-lang.org/core/cmp/trait.PartialEq.html) and [`PartialOrd`](https://doc.rust-lang.org/core/cmp/trait.PartialOrd.html), which is what std uses, with
0 commit comments