Skip to content

Commit

Permalink
added example back in, with a modified, (hopefully) improved description
Browse files Browse the repository at this point in the history
  • Loading branch information
Junseok Lee committed Feb 6, 2015
1 parent b6544fd commit 310ada0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 310ada0

Please sign in to comment.