Skip to content

Commit 95b50eb

Browse files
Rollup merge of #87904 - kpreid:unsize, r=jyn514
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. I have no particular knowledge of `Unsize`; I have attempted to leave the meaning entirely unchanged but may have missed a nuance. Markdown preview of the edited documentation: > All implementations of `Unsize` are provided automatically by the compiler. > 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.
2 parents 641e02f + 07988bb commit 95b50eb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

library/core/src/marker.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,15 @@ pub trait Sized {
9999
/// `Unsize<dyn fmt::Debug>`.
100100
///
101101
/// All implementations of `Unsize` are provided automatically by the compiler.
102-
///
103-
/// `Unsize` is implemented for:
104-
///
105-
/// - `[T; N]` is `Unsize<[T]>`
106-
/// - `T` is `Unsize<dyn Trait>` when `T: Trait`
107-
/// - `Foo<..., T, ...>` is `Unsize<Foo<..., U, ...>>` if:
108-
/// - `T: Unsize<U>`
109-
/// - Foo is a struct
110-
/// - Only the last field of `Foo` has a type involving `T`
111-
/// - `T` is not part of the type of any other fields
112-
/// - `Bar<T>: Unsize<Bar<U>>`, if the last field of `Foo` has type `Bar<T>`
102+
/// Those implementations are:
103+
///
104+
/// - Arrays `[T; N]` implement `Unsize<[T]>`.
105+
/// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
106+
/// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
107+
/// are met:
108+
/// - `T: Unsize<U>`.
109+
/// - Only the last field of `Foo` has a type involving `T`.
110+
/// - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
113111
///
114112
/// `Unsize` is used along with [`ops::CoerceUnsized`] to allow
115113
/// "user-defined" containers such as [`Rc`] to contain dynamically-sized

0 commit comments

Comments
 (0)