Skip to content

Commit e921afd

Browse files
committed
Stabilize core::ops
This commit marks as stable those parts of `core::ops` that are in their final planned form: `Drop`, all of the mathematical operators (`Add`, `Sub`, etc), `Deref`/`DerefMut`. It leaves the `Index*`, `Slice*` and `Fn*` traits unstable, as they are still undergoing active changes.
1 parent 64ec47c commit e921afd

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

src/libcore/ops.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
//! See the documentation for each trait for a minimum implementation that prints
6060
//! something to the screen.
6161
62+
#![stable]
63+
6264
use clone::Clone;
6365
use iter::{Step, Iterator,DoubleEndedIterator,ExactSizeIterator};
6466
use kinds::Sized;
@@ -86,8 +88,10 @@ use option::Option::{self, Some, None};
8688
/// }
8789
/// ```
8890
#[lang="drop"]
91+
#[stable]
8992
pub trait Drop {
9093
/// The `drop` method, called when the value goes out of scope.
94+
#[stable]
9195
fn drop(&mut self);
9296
}
9397

@@ -120,15 +124,19 @@ pub trait Drop {
120124
/// }
121125
/// ```
122126
#[lang="add"]
127+
#[stable]
123128
pub trait Add<RHS=Self> {
129+
#[stable]
124130
type Output;
125131

126132
/// The method for the `+` operator
133+
#[stable]
127134
fn add(self, rhs: RHS) -> Self::Output;
128135
}
129136

130137
macro_rules! add_impl {
131138
($($t:ty)*) => ($(
139+
#[stable]
132140
impl Add for $t {
133141
type Output = $t;
134142

@@ -169,15 +177,19 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
169177
/// }
170178
/// ```
171179
#[lang="sub"]
180+
#[stable]
172181
pub trait Sub<RHS=Self> {
182+
#[stable]
173183
type Output;
174184

175185
/// The method for the `-` operator
186+
#[stable]
176187
fn sub(self, rhs: RHS) -> Self::Output;
177188
}
178189

179190
macro_rules! sub_impl {
180191
($($t:ty)*) => ($(
192+
#[stable]
181193
impl Sub for $t {
182194
type Output = $t;
183195

@@ -218,15 +230,19 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
218230
/// }
219231
/// ```
220232
#[lang="mul"]
233+
#[stable]
221234
pub trait Mul<RHS=Self> {
235+
#[stable]
222236
type Output;
223237

224238
/// The method for the `*` operator
239+
#[stable]
225240
fn mul(self, rhs: RHS) -> Self::Output;
226241
}
227242

228243
macro_rules! mul_impl {
229244
($($t:ty)*) => ($(
245+
#[stable]
230246
impl Mul for $t {
231247
type Output = $t;
232248

@@ -267,15 +283,19 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
267283
/// }
268284
/// ```
269285
#[lang="div"]
286+
#[stable]
270287
pub trait Div<RHS=Self> {
288+
#[stable]
271289
type Output;
272290

273291
/// The method for the `/` operator
292+
#[stable]
274293
fn div(self, rhs: RHS) -> Self::Output;
275294
}
276295

277296
macro_rules! div_impl {
278297
($($t:ty)*) => ($(
298+
#[stable]
279299
impl Div for $t {
280300
type Output = $t;
281301

@@ -316,15 +336,19 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
316336
/// }
317337
/// ```
318338
#[lang="rem"]
339+
#[stable]
319340
pub trait Rem<RHS=Self> {
341+
#[stable]
320342
type Output = Self;
321343

322344
/// The method for the `%` operator
345+
#[stable]
323346
fn rem(self, rhs: RHS) -> Self::Output;
324347
}
325348

326349
macro_rules! rem_impl {
327350
($($t:ty)*) => ($(
351+
#[stable]
328352
impl Rem for $t {
329353
type Output = $t;
330354

@@ -336,6 +360,7 @@ macro_rules! rem_impl {
336360

337361
macro_rules! rem_float_impl {
338362
($t:ty, $fmod:ident) => {
363+
#[stable]
339364
impl Rem for $t {
340365
type Output = $t;
341366

@@ -382,26 +407,33 @@ rem_float_impl! { f64, fmod }
382407
/// }
383408
/// ```
384409
#[lang="neg"]
410+
#[stable]
385411
pub trait Neg {
412+
#[stable]
386413
type Output;
387414

388415
/// The method for the unary `-` operator
416+
#[stable]
389417
fn neg(self) -> Self::Output;
390418
}
391419

392420
macro_rules! neg_impl {
393421
($($t:ty)*) => ($(
422+
#[stable]
394423
impl Neg for $t {
424+
#[stable]
395425
type Output = $t;
396426

397427
#[inline]
428+
#[stable]
398429
fn neg(self) -> $t { -self }
399430
}
400431
)*)
401432
}
402433

403434
macro_rules! neg_uint_impl {
404435
($t:ty, $t_signed:ty) => {
436+
#[stable]
405437
impl Neg for $t {
406438
type Output = $t;
407439

@@ -450,15 +482,19 @@ neg_uint_impl! { u64, i64 }
450482
/// }
451483
/// ```
452484
#[lang="not"]
485+
#[stable]
453486
pub trait Not {
487+
#[stable]
454488
type Output;
455489

456490
/// The method for the unary `!` operator
491+
#[stable]
457492
fn not(self) -> Self::Output;
458493
}
459494

460495
macro_rules! not_impl {
461496
($($t:ty)*) => ($(
497+
#[stable]
462498
impl Not for $t {
463499
type Output = $t;
464500

@@ -499,15 +535,19 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
499535
/// }
500536
/// ```
501537
#[lang="bitand"]
538+
#[stable]
502539
pub trait BitAnd<RHS=Self> {
540+
#[stable]
503541
type Output;
504542

505543
/// The method for the `&` operator
544+
#[stable]
506545
fn bitand(self, rhs: RHS) -> Self::Output;
507546
}
508547

509548
macro_rules! bitand_impl {
510549
($($t:ty)*) => ($(
550+
#[stable]
511551
impl BitAnd for $t {
512552
type Output = $t;
513553

@@ -548,15 +588,19 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
548588
/// }
549589
/// ```
550590
#[lang="bitor"]
591+
#[stable]
551592
pub trait BitOr<RHS=Self> {
593+
#[stable]
552594
type Output;
553595

554596
/// The method for the `|` operator
597+
#[stable]
555598
fn bitor(self, rhs: RHS) -> Self::Output;
556599
}
557600

558601
macro_rules! bitor_impl {
559602
($($t:ty)*) => ($(
603+
#[stable]
560604
impl BitOr for $t {
561605
type Output = $t;
562606

@@ -597,15 +641,19 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
597641
/// }
598642
/// ```
599643
#[lang="bitxor"]
644+
#[stable]
600645
pub trait BitXor<RHS=Self> {
646+
#[stable]
601647
type Output;
602648

603649
/// The method for the `^` operator
650+
#[stable]
604651
fn bitxor(self, rhs: RHS) -> Self::Output;
605652
}
606653

607654
macro_rules! bitxor_impl {
608655
($($t:ty)*) => ($(
656+
#[stable]
609657
impl BitXor for $t {
610658
type Output = $t;
611659

@@ -646,15 +694,19 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
646694
/// }
647695
/// ```
648696
#[lang="shl"]
697+
#[stable]
649698
pub trait Shl<RHS> {
699+
#[stable]
650700
type Output;
651701

652702
/// The method for the `<<` operator
703+
#[stable]
653704
fn shl(self, rhs: RHS) -> Self::Output;
654705
}
655706

656707
macro_rules! shl_impl {
657708
($($t:ty)*) => ($(
709+
#[stable]
658710
impl Shl<uint> for $t {
659711
type Output = $t;
660712

@@ -697,10 +749,13 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
697749
/// }
698750
/// ```
699751
#[lang="shr"]
752+
#[stable]
700753
pub trait Shr<RHS> {
754+
#[stable]
701755
type Output;
702756

703757
/// The method for the `>>` operator
758+
#[stable]
704759
fn shr(self, rhs: RHS) -> Self::Output;
705760
}
706761

@@ -913,11 +968,13 @@ pub trait SliceMut<Sized? Idx, Sized? Result> for Sized? {
913968
/// An unbounded range.
914969
#[derive(Copy)]
915970
#[lang="full_range"]
971+
#[unstable = "API still in development"]
916972
pub struct FullRange;
917973

918974
/// A (half-open) range which is bounded at both ends.
919975
#[derive(Copy)]
920976
#[lang="range"]
977+
#[unstable = "API still in development"]
921978
pub struct Range<Idx> {
922979
/// The lower bound of the range (inclusive).
923980
pub start: Idx,
@@ -968,6 +1025,7 @@ impl<Idx: Clone + Step> ExactSizeIterator for Range<Idx> {}
9681025
/// A range which is only bounded below.
9691026
#[derive(Copy)]
9701027
#[lang="range_from"]
1028+
#[unstable = "API still in development"]
9711029
pub struct RangeFrom<Idx> {
9721030
/// The lower bound of the range (inclusive).
9731031
pub start: Idx,
@@ -988,6 +1046,7 @@ impl<Idx: Clone + Step> Iterator for RangeFrom<Idx> {
9881046
/// A range which is only bounded above.
9891047
#[derive(Copy)]
9901048
#[lang="range_to"]
1049+
#[unstable = "API still in development"]
9911050
pub struct RangeTo<Idx> {
9921051
/// The upper bound of the range (exclusive).
9931052
pub end: Idx,
@@ -1025,19 +1084,24 @@ pub struct RangeTo<Idx> {
10251084
/// }
10261085
/// ```
10271086
#[lang="deref"]
1087+
#[stable]
10281088
pub trait Deref for Sized? {
1089+
#[stable]
10291090
type Sized? Target;
10301091

10311092
/// The method called to dereference a value
1093+
#[stable]
10321094
fn deref<'a>(&'a self) -> &'a Self::Target;
10331095
}
10341096

1097+
#[stable]
10351098
impl<'a, Sized? T> Deref for &'a T {
10361099
type Target = T;
10371100

10381101
fn deref(&self) -> &T { *self }
10391102
}
10401103

1104+
#[stable]
10411105
impl<'a, Sized? T> Deref for &'a mut T {
10421106
type Target = T;
10431107

@@ -1082,31 +1146,37 @@ impl<'a, Sized? T> Deref for &'a mut T {
10821146
/// }
10831147
/// ```
10841148
#[lang="deref_mut"]
1149+
#[stable]
10851150
pub trait DerefMut for Sized? : Deref {
10861151
/// The method called to mutably dereference a value
1152+
#[stable]
10871153
fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target;
10881154
}
10891155

1156+
#[stable]
10901157
impl<'a, Sized? T> DerefMut for &'a mut T {
10911158
fn deref_mut(&mut self) -> &mut T { *self }
10921159
}
10931160

10941161
/// A version of the call operator that takes an immutable receiver.
10951162
#[lang="fn"]
1163+
#[unstable = "uncertain about variadic generics, input versus associated types"]
10961164
pub trait Fn<Args,Result> for Sized? {
10971165
/// This is called when the call operator is used.
10981166
extern "rust-call" fn call(&self, args: Args) -> Result;
10991167
}
11001168

11011169
/// A version of the call operator that takes a mutable receiver.
11021170
#[lang="fn_mut"]
1171+
#[unstable = "uncertain about variadic generics, input versus associated types"]
11031172
pub trait FnMut<Args,Result> for Sized? {
11041173
/// This is called when the call operator is used.
11051174
extern "rust-call" fn call_mut(&mut self, args: Args) -> Result;
11061175
}
11071176

11081177
/// A version of the call operator that takes a by-value receiver.
11091178
#[lang="fn_once"]
1179+
#[unstable = "uncertain about variadic generics, input versus associated types"]
11101180
pub trait FnOnce<Args,Result> {
11111181
/// This is called when the call operator is used.
11121182
extern "rust-call" fn call_once(self, args: Args) -> Result;

0 commit comments

Comments
 (0)