mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 23:33:00 +00:00
update "since" for discriminant_value
It's going to be backported to beta.
This commit is contained in:
parent
539f2083de
commit
5f43357782
@ -712,39 +712,39 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
/// Opaque type representing the discriminant of an enum.
|
||||
///
|
||||
/// See the `discriminant` function in this module for more information.
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
pub struct Discriminant<T>(u64, PhantomData<*const T>);
|
||||
|
||||
// N.B. These trait implementations cannot be derived because we don't want any bounds on T.
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> Copy for Discriminant<T> {}
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> clone::Clone for Discriminant<T> {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> cmp::PartialEq for Discriminant<T> {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
self.0 == rhs.0
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> cmp::Eq for Discriminant<T> {}
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> hash::Hash for Discriminant<T> {
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.0.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
impl<T> fmt::Debug for Discriminant<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt.debug_tuple("Discriminant")
|
||||
@ -777,7 +777,7 @@ impl<T> fmt::Debug for Discriminant<T> {
|
||||
/// assert!(mem::discriminant(&Foo::B(1)) == mem::discriminant(&Foo::B(2)));
|
||||
/// assert!(mem::discriminant(&Foo::B(3)) != mem::discriminant(&Foo::C(3)));
|
||||
/// ```
|
||||
#[stable(feature = "discriminant_value", since = "1.22.0")]
|
||||
#[stable(feature = "discriminant_value", since = "1.21.0")]
|
||||
pub fn discriminant<T>(v: &T) -> Discriminant<T> {
|
||||
unsafe {
|
||||
Discriminant(intrinsics::discriminant_value(v), PhantomData)
|
||||
|
Loading…
Reference in New Issue
Block a user