From 299be33a4aa77a5df9e6d2be58bb44c4152721a9 Mon Sep 17 00:00:00 2001 From: Connor Horman Date: Wed, 21 Aug 2024 21:24:38 -0400 Subject: [PATCH 1/2] Add spec identifiers to dynamically-sized-types.md --- src/dynamically-sized-types.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/dynamically-sized-types.md b/src/dynamically-sized-types.md index cab1ec510..739c06338 100644 --- a/src/dynamically-sized-types.md +++ b/src/dynamically-sized-types.md @@ -1,22 +1,35 @@ # Dynamically Sized Types +r[dynamic-sized-types] + +r[dynamic-sized.intro] Most types have a fixed size that is known at compile time and implement the trait [`Sized`][sized]. A type with a size that is known only at run-time is called a _dynamically sized type_ (_DST_) or, informally, an unsized type. [Slices] and [trait objects] are two examples of DSTs. Such types can only be used in certain cases: +types">DSTs. + +r[dynamic-sized.restriction] +Such types can only be used in certain cases: +r[dynamic-sized.pointer-types] * [Pointer types] to DSTs are sized but have twice the size of pointers to sized types * Pointers to slices also store the number of elements of the slice. * Pointers to trait objects also store a pointer to a vtable. + +r[dynamic-sized.question-sized] * DSTs can be provided as type arguments to generic type parameters having the special `?Sized` bound. They can also be used for associated type definitions when the corresponding associated type declaration has a `?Sized` bound. By default, any type parameter or associated type has a `Sized` bound, unless it is relaxed using `?Sized`. + +r[dynamic-sized.trait-impl] * Traits may be implemented for DSTs. Unlike with generic type parameters, `Self: ?Sized` is the default in trait definitions. + +r[dynamic-sized.struct-field] * Structs may contain a DST as the last field; this makes the struct itself a DST. From fd471e827ed61052d4c750ed8141f94050d6db16 Mon Sep 17 00:00:00 2001 From: Connor Horman Date: Wed, 11 Dec 2024 18:53:40 -0500 Subject: [PATCH 2/2] Fix identifier dynamic-sized-types --- src/dynamically-sized-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamically-sized-types.md b/src/dynamically-sized-types.md index 739c06338..e65d3e022 100644 --- a/src/dynamically-sized-types.md +++ b/src/dynamically-sized-types.md @@ -1,6 +1,6 @@ # Dynamically Sized Types -r[dynamic-sized-types] +r[dynamic-sized] r[dynamic-sized.intro] Most types have a fixed size that is known at compile time and implement the