mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-30 00:23:41 +00:00
Auto merge of #21995 - leejunseok:fix_invariant_ex, r=steveklabnik
Should fix #20147 This is my second PR in the history of ever (I botched my first one #21828). Any tips would be appreciated!
This commit is contained in:
commit
a08504bb35
@ -311,16 +311,17 @@ impl<T: ?Sized> Clone for ContravariantType<T> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// The Cell type is an example which uses unsafe code to achieve
|
||||
/// "interior" mutability:
|
||||
/// 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.
|
||||
/// 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"]
|
||||
|
Loading…
Reference in New Issue
Block a user