Struct std::ty::Unsafe
pub struct Unsafe<T> { value: T, marker1: InvariantType<T>, }
Unsafe type that wraps a type T and indicates unsafe interior operations on the
wrapped type. Types with an Unsafe<T>
field are considered to have an unsafe
interior. The Unsafe type is the only legal way to obtain aliasable data that is
considered mutable. In general, transmuting an &T type into an &mut T is considered
undefined behavior.
Although it is possible to put an Unsafe
Types like Cell
and RefCell
use this type to wrap their internal data.
Unsafe doesn't opt-out from any kind, instead, types with an Unsafe
interior
are expected to opt-out from kinds themselves.
Example:
use std::ty::Unsafe; use std::kinds::marker; struct NotThreadSafe<T> { value: Unsafe<T>, marker1: marker::NoShare }
NOTE: Unsafeget
should be used instead.
Fields
value | Wrapped value |
marker1 | Invariance marker |