about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-11-01 20:16:24 +0000
committerMichael Goulet <michael@errs.io>2023-11-01 20:16:24 +0000
commit1221b7b652a9859340fad0cd6db78c7493f3847f (patch)
treef866bc5d4678e12a5937ad4bf5dd3b18239a94b7 /library/core
parent6af30ec720c3a8f074b61c9003b7e63f78f148a0 (diff)
downloadrust-1221b7b652a9859340fad0cd6db78c7493f3847f.tar.gz
rust-1221b7b652a9859340fad0cd6db78c7493f3847f.zip
Rework unsize documentation
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/marker.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 39e4abb10e9..13437d8f961 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -155,11 +155,18 @@ pub trait Sized {
 /// 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:
-///   - 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.
+/// - A type implements `Unsize<dyn Trait + 'a>` if all of these conditions are met:
+///   - The type implements `Trait`.
+///   - `Trait` is object safe.
+///   - The type is sized.
+///   - The type outlives `'a`.
+/// - Structs `Foo<..., T1, ..., Tn, ...>` implement `Unsize<Foo<..., U1, ..., Un, ...>>`
+/// where any number of (type and const) parameters may be changed if all of these conditions
+/// are met:
+///   - Only the last field of `Foo` has a type involving the parameters `T1`, ..., `Tn`.
+///   - All other parameters of the struct are equal.
+///   - `Field<T1, ..., Tn>: Unsize<Field<U1, ..., Un>>`, where `Field<...>` stands for the actual
+///     type of the struct's last field.
 ///
 /// `Unsize` is used along with [`ops::CoerceUnsized`] to allow
 /// "user-defined" containers such as [`Rc`] to contain dynamically-sized