about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Reid <kpreid@google.com>2021-08-09 18:26:58 -0700
committerKevin Reid <kpreid@google.com>2021-08-09 18:55:39 -0700
commit07988bb8a1ce5b6732d351c4299f0b0a4d51e192 (patch)
tree0de05777f71e452d1dd7bfef37ac8b35bddc3bbc
parentae90dcf0207c57c3034f00b07048d63f8b2363c8 (diff)
downloadrust-07988bb8a1ce5b6732d351c4299f0b0a4d51e192.tar.gz
rust-07988bb8a1ce5b6732d351c4299f0b0a4d51e192.zip
Reword description of automatic impls of `Unsize`.
The existing documentation felt a little unhelpfully concise, so this
change tries to improve it by using longer sentences, each of which
specifies which kinds of types it applies to as early as possible. In
particular, the third item starts with “Structs ...” instead of
saying “Foo is a struct” later.

Also, the previous list items “Only the last field has a type
involving `T`” and “`T` is not part of the type of any other
fields” are, as far as I see, redundant with each other, so I removed
the latter.
-rw-r--r--library/core/src/marker.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index fb957348beb..556b1a721d3 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -99,17 +99,15 @@ pub trait Sized {
 /// `Unsize<dyn fmt::Debug>`.
 ///
 /// All implementations of `Unsize` are provided automatically by the compiler.
-///
-/// `Unsize` is implemented for:
-///
-/// - `[T; N]` is `Unsize<[T]>`
-/// - `T` is `Unsize<dyn Trait>` when `T: Trait`
-/// - `Foo<..., T, ...>` is `Unsize<Foo<..., U, ...>>` if:
-///   - `T: Unsize<U>`
-///   - Foo is a struct
-///   - Only the last field of `Foo` has a type involving `T`
-///   - `T` is not part of the type of any other fields
-///   - `Bar<T>: Unsize<Bar<U>>`, if the last field of `Foo` has type `Bar<T>`
+/// Those implementations are:
+///
+/// - Arrays `[T; N]` implement `Unsize<[T]>`.
+/// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
+/// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
+///   are met:
+///   - `T: Unsize<U>`.
+///   - Only the last field of `Foo` has a type involving `T`.
+///   - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
 ///
 /// `Unsize` is used along with [`ops::CoerceUnsized`] to allow
 /// "user-defined" containers such as [`Rc`] to contain dynamically-sized