diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-11-22 23:01:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-22 23:01:00 +0100 |
| commit | 8a623e6f98787689381a52308acb4925a358f05b (patch) | |
| tree | cbcc3a4e066487aeb5a7bfaadfbd06821bac775c | |
| parent | b249844c33f5327cbba7a13d34eaaf290f0ec776 (diff) | |
| parent | b813c727235c48e9142726699dae2e0423fd57d9 (diff) | |
| download | rust-8a623e6f98787689381a52308acb4925a358f05b.tar.gz rust-8a623e6f98787689381a52308acb4925a358f05b.zip | |
Rollup merge of #78793 - camelid:fixup-structuraleq, r=jyn514
Clean up `StructuralEq` docs
| -rw-r--r-- | library/core/src/marker.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index cdf742057b7..29364d0ce9b 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -156,18 +156,18 @@ pub trait StructuralPartialEq { /// Required trait for constants used in pattern matches. /// /// Any type that derives `Eq` automatically implements this trait, *regardless* -/// of whether its type-parameters implement `Eq`. +/// of whether its type parameters implement `Eq`. /// -/// This is a hack to workaround a limitation in our type-system. +/// This is a hack to work around a limitation in our type system. /// -/// Background: +/// # Background /// /// We want to require that types of consts used in pattern matches /// have the attribute `#[derive(PartialEq, Eq)]`. /// /// In a more ideal world, we could check that requirement by just checking that -/// the given type implements both (1.) the `StructuralPartialEq` trait *and* -/// (2.) the `Eq` trait. However, you can have ADTs that *do* `derive(PartialEq, Eq)`, +/// the given type implements both the `StructuralPartialEq` trait *and* +/// the `Eq` trait. However, you can have ADTs that *do* `derive(PartialEq, Eq)`, /// and be a case that we want the compiler to accept, and yet the constant's /// type fails to implement `Eq`. /// @@ -176,8 +176,11 @@ pub trait StructuralPartialEq { /// ```rust /// #[derive(PartialEq, Eq)] /// struct Wrap<X>(X); +/// /// fn higher_order(_: &()) { } +/// /// const CFN: Wrap<fn(&())> = Wrap(higher_order); +/// /// fn main() { /// match CFN { /// CFN => {} |
