mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add const_trait
s
This commit is contained in:
parent
81b1810cd7
commit
be65e03676
@ -154,6 +154,7 @@
|
||||
/// [`String`]: ../../std/string/struct.String.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "Borrow"]
|
||||
#[const_trait]
|
||||
pub trait Borrow<Borrowed: ?Sized> {
|
||||
/// Immutably borrows from an owned value.
|
||||
///
|
||||
@ -184,6 +185,7 @@ pub trait Borrow<Borrowed: ?Sized> {
|
||||
/// an underlying type by providing a mutable reference. See [`Borrow<T>`]
|
||||
/// for more information on borrowing as another type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[const_trait]
|
||||
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
|
||||
/// Mutably borrows from an owned value.
|
||||
///
|
||||
|
@ -228,6 +228,7 @@ pub trait FromIterator<A>: Sized {
|
||||
#[rustc_diagnostic_item = "IntoIterator"]
|
||||
#[rustc_skip_array_during_method_dispatch]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[const_trait]
|
||||
pub trait IntoIterator {
|
||||
/// The type of the elements being iterated over.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -938,6 +938,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
)]
|
||||
#[doc(alias = "/")]
|
||||
#[doc(alias = "/=")]
|
||||
#[const_trait]
|
||||
pub trait DivAssign<Rhs = Self> {
|
||||
/// Performs the `/=` operation.
|
||||
///
|
||||
@ -999,6 +1000,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
)]
|
||||
#[doc(alias = "%")]
|
||||
#[doc(alias = "%=")]
|
||||
#[const_trait]
|
||||
pub trait RemAssign<Rhs = Self> {
|
||||
/// Performs the `%=` operation.
|
||||
///
|
||||
|
@ -31,6 +31,7 @@
|
||||
#[lang = "not"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(alias = "!")]
|
||||
#[const_trait]
|
||||
pub trait Not {
|
||||
/// The resulting type after applying the `!` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -906,6 +907,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||
message = "no implementation for `{Self} <<= {Rhs}`",
|
||||
label = "no implementation for `{Self} <<= {Rhs}`"
|
||||
)]
|
||||
#[const_trait]
|
||||
pub trait ShlAssign<Rhs = Self> {
|
||||
/// Performs the `<<=` operation.
|
||||
///
|
||||
@ -989,6 +991,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
|
||||
message = "no implementation for `{Self} >>= {Rhs}`",
|
||||
label = "no implementation for `{Self} >>= {Rhs}`"
|
||||
)]
|
||||
#[const_trait]
|
||||
pub trait ShrAssign<Rhs = Self> {
|
||||
/// Performs the `>>=` operation.
|
||||
///
|
||||
|
@ -61,6 +61,7 @@
|
||||
#[doc(alias = "&*")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "Deref"]
|
||||
#[const_trait]
|
||||
pub trait Deref {
|
||||
/// The resulting type after dereferencing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -128,6 +128,7 @@ use crate::ops::ControlFlow;
|
||||
)]
|
||||
#[doc(alias = "?")]
|
||||
#[lang = "Try"]
|
||||
#[const_trait]
|
||||
pub trait Try: FromResidual {
|
||||
/// The type of the value produced by `?` when *not* short-circuiting.
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
@ -384,6 +385,7 @@ pub trait Try: FromResidual {
|
||||
))]
|
||||
#[rustc_diagnostic_item = "FromResidual"]
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
#[const_trait]
|
||||
pub trait FromResidual<R = <Self as Try>::Residual> {
|
||||
/// Constructs the type from a compatible `Residual` type.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user