From dc61d0f0938f500dd3558b3989a24ad3bc7e20a8 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 18 Oct 2015 04:17:33 -0700 Subject: [PATCH] Document DST parameters on std::marker::Sized This is for discoverability. If someone wants to know what ?Sized means, then Sized will be the only keyword they can use to search; so even though this is technically a language matter, it makes sense to document it where it will be looked for. --- src/libcore/marker.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index f9480b4349d..27d8af2e8a8 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -36,6 +36,17 @@ impl !Send for *const T { } impl !Send for *mut T { } /// Types with a constant size known at compile-time. +/// +/// All type parameters which can be bounded have an implicit bound of `Sized`. The special syntax +/// `?Sized` can be used to remove this bound if it is not appropriate. +/// +/// ``` +/// struct Foo(T); +/// struct Bar(T); +/// +/// // struct FooUse(Foo<[i32]>); // error: Sized is not implemented for [i32] +/// struct BarUse(Bar<[i32]>); // OK +/// ``` #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sized"] #[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]