Skip to content

Commit 1221b7b

Browse files
Rework unsize documentation
1 parent 6af30ec commit 1221b7b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

library/core/src/marker.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,18 @@ pub trait Sized {
155155
/// Those implementations are:
156156
///
157157
/// - Arrays `[T; N]` implement `Unsize<[T]>`.
158-
/// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
159-
/// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
160-
/// are met:
161-
/// - Only the last field of `Foo` has a type involving `T`.
162-
/// - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
158+
/// - A type implements `Unsize<dyn Trait + 'a>` if all of these conditions are met:
159+
/// - The type implements `Trait`.
160+
/// - `Trait` is object safe.
161+
/// - The type is sized.
162+
/// - The type outlives `'a`.
163+
/// - Structs `Foo<..., T1, ..., Tn, ...>` implement `Unsize<Foo<..., U1, ..., Un, ...>>`
164+
/// where any number of (type and const) parameters may be changed if all of these conditions
165+
/// are met:
166+
/// - Only the last field of `Foo` has a type involving the parameters `T1`, ..., `Tn`.
167+
/// - All other parameters of the struct are equal.
168+
/// - `Field<T1, ..., Tn>: Unsize<Field<U1, ..., Un>>`, where `Field<...>` stands for the actual
169+
/// type of the struct's last field.
163170
///
164171
/// `Unsize` is used along with [`ops::CoerceUnsized`] to allow
165172
/// "user-defined" containers such as [`Rc`] to contain dynamically-sized

0 commit comments

Comments
 (0)