From b6544fd3520d5eed05aafeb6b78737e32bf2c435 Mon Sep 17 00:00:00 2001 From: Junseok Lee Date: Sat, 31 Jan 2015 18:21:57 -0800 Subject: [PATCH 1/2] removed weird example --- src/libcore/marker.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 299cdbda3cc74..ab64d09f9d43f 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -308,19 +308,6 @@ impl Clone for ContravariantType { /// /// For more information about variance, refer to this Wikipedia /// article . -/// -/// # Example -/// -/// The Cell type is an example which uses unsafe code to achieve -/// "interior" mutability: -/// -/// ``` -/// struct Cell { value: T } -/// ``` -/// -/// The type system would infer that `value` is only read here and -/// never written, but in fact `Cell` uses unsafe code to achieve -/// interior mutability. #[unstable(feature = "core", reason = "likely to change with new variance strategy")] #[lang="invariant_type"] From 310ada06f2d632340845ccd4d7e68a1b54d2f28a Mon Sep 17 00:00:00 2001 From: Junseok Lee Date: Thu, 5 Feb 2015 23:46:30 -0800 Subject: [PATCH 2/2] added example back in, with a modified, (hopefully) improved description --- src/libcore/marker.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index ab64d09f9d43f..b8fef6a619d46 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -308,6 +308,20 @@ impl Clone for ContravariantType { /// /// For more information about variance, refer to this Wikipedia /// article . +/// +/// # Example +/// +/// The Cell type is an example of an `InvariantType` which uses unsafe +/// code to achieve "interior" mutability: +/// +/// ``` +/// struct Cell { value: T } +/// ``` +/// +/// The type system would infer that `value` is only read here +/// and never written, but in fact `Cell` uses unsafe code to achieve +/// interior mutability. In order to get correct behavior, the +/// `InvariantType` marker must be applied. #[unstable(feature = "core", reason = "likely to change with new variance strategy")] #[lang="invariant_type"]