about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorJunseok Lee <lee.junseok@berkeley.edu>2015-02-05 23:46:30 -0800
committerJunseok Lee <lee.junseok@berkeley.edu>2015-02-05 23:50:51 -0800
commit310ada06f2d632340845ccd4d7e68a1b54d2f28a (patch)
tree16f37d00d24b160666662a3efb40ffe9694dd697 /src/libcore
parentb6544fd3520d5eed05aafeb6b78737e32bf2c435 (diff)
downloadrust-310ada06f2d632340845ccd4d7e68a1b54d2f28a.tar.gz
rust-310ada06f2d632340845ccd4d7e68a1b54d2f28a.zip
added example back in, with a modified, (hopefully) improved description
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/marker.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index ab64d09f9d4..b8fef6a619d 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -308,6 +308,20 @@ impl<T: ?Sized> Clone for ContravariantType<T> {
 ///
 /// For more information about variance, refer to this Wikipedia
 /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// # Example
+///
+/// The Cell type is an example of an `InvariantType` which uses unsafe
+/// code to achieve "interior" mutability:
+///
+/// ```
+/// struct Cell<T> { 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"]