Skip to content

Commit f3a80ab

Browse files
committed
Apply stability attributes to core::num::{Int, SignedInt, UnsignedInt}.
1 parent 49feb0c commit f3a80ab

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

src/libcore/num/mod.rs

+40-11
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use option::Option::{Some, None};
3030
use str::{FromStr, StrExt};
3131

3232
/// A built-in signed or unsigned integer.
33-
#[unstable = "recently settled as part of numerics reform"]
33+
#[stable]
3434
pub trait Int
3535
: Copy + Clone
3636
+ NumCast
@@ -50,18 +50,22 @@ pub trait Int
5050
{
5151
/// Returns the `0` value of this integer type.
5252
// FIXME (#5527): Should be an associated constant
53+
#[unstable = "unsure about its place in the world"]
5354
fn zero() -> Self;
5455

5556
/// Returns the `1` value of this integer type.
5657
// FIXME (#5527): Should be an associated constant
58+
#[unstable = "unsure about its place in the world"]
5759
fn one() -> Self;
5860

5961
/// Returns the smallest value that can be represented by this integer type.
6062
// FIXME (#5527): Should be and associated constant
63+
#[unstable = "unsure about its place in the world"]
6164
fn min_value() -> Self;
6265

6366
/// Returns the largest value that can be represented by this integer type.
6467
// FIXME (#5527): Should be and associated constant
68+
#[unstable = "unsure about its place in the world"]
6569
fn max_value() -> Self;
6670

6771
/// Returns the number of ones in the binary representation of `self`.
@@ -75,6 +79,7 @@ pub trait Int
7579
///
7680
/// assert_eq!(n.count_ones(), 3);
7781
/// ```
82+
#[unstable = "pending integer conventions"]
7883
fn count_ones(self) -> uint;
7984

8085
/// Returns the number of zeros in the binary representation of `self`.
@@ -88,6 +93,7 @@ pub trait Int
8893
///
8994
/// assert_eq!(n.count_zeros(), 5);
9095
/// ```
96+
#[unstable = "pending integer conventions"]
9197
#[inline]
9298
fn count_zeros(self) -> uint {
9399
(!self).count_ones()
@@ -105,6 +111,7 @@ pub trait Int
105111
///
106112
/// assert_eq!(n.leading_zeros(), 10);
107113
/// ```
114+
#[unstable = "pending integer conventions"]
108115
fn leading_zeros(self) -> uint;
109116

110117
/// Returns the number of trailing zeros in the binary representation
@@ -119,6 +126,7 @@ pub trait Int
119126
///
120127
/// assert_eq!(n.trailing_zeros(), 3);
121128
/// ```
129+
#[unstable = "pending integer conventions"]
122130
fn trailing_zeros(self) -> uint;
123131

124132
/// Shifts the bits to the left by a specified amount amount, `n`, wrapping
@@ -134,6 +142,7 @@ pub trait Int
134142
///
135143
/// assert_eq!(n.rotate_left(12), m);
136144
/// ```
145+
#[unstable = "pending integer conventions"]
137146
fn rotate_left(self, n: uint) -> Self;
138147

139148
/// Shifts the bits to the right by a specified amount amount, `n`, wrapping
@@ -149,6 +158,7 @@ pub trait Int
149158
///
150159
/// assert_eq!(n.rotate_right(12), m);
151160
/// ```
161+
#[unstable = "pending integer conventions"]
152162
fn rotate_right(self, n: uint) -> Self;
153163

154164
/// Reverses the byte order of the integer.
@@ -163,6 +173,7 @@ pub trait Int
163173
///
164174
/// assert_eq!(n.swap_bytes(), m);
165175
/// ```
176+
#[stable]
166177
fn swap_bytes(self) -> Self;
167178

168179
/// Convert an integer from big endian to the target's endianness.
@@ -182,6 +193,7 @@ pub trait Int
182193
/// assert_eq!(Int::from_be(n), n.swap_bytes())
183194
/// }
184195
/// ```
196+
#[stable]
185197
#[inline]
186198
fn from_be(x: Self) -> Self {
187199
if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
@@ -204,6 +216,7 @@ pub trait Int
204216
/// assert_eq!(Int::from_le(n), n.swap_bytes())
205217
/// }
206218
/// ```
219+
#[stable]
207220
#[inline]
208221
fn from_le(x: Self) -> Self {
209222
if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
@@ -226,6 +239,7 @@ pub trait Int
226239
/// assert_eq!(n.to_be(), n.swap_bytes())
227240
/// }
228241
/// ```
242+
#[stable]
229243
#[inline]
230244
fn to_be(self) -> Self { // or not to be?
231245
if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
@@ -248,6 +262,7 @@ pub trait Int
248262
/// assert_eq!(n.to_le(), n.swap_bytes())
249263
/// }
250264
/// ```
265+
#[stable]
251266
#[inline]
252267
fn to_le(self) -> Self {
253268
if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
@@ -264,6 +279,7 @@ pub trait Int
264279
/// assert_eq!(5u16.checked_add(65530), Some(65535));
265280
/// assert_eq!(6u16.checked_add(65530), None);
266281
/// ```
282+
#[stable]
267283
fn checked_add(self, other: Self) -> Option<Self>;
268284

269285
/// Checked integer subtraction. Computes `self - other`, returning `None`
@@ -277,6 +293,7 @@ pub trait Int
277293
/// assert_eq!((-127i8).checked_sub(1), Some(-128));
278294
/// assert_eq!((-128i8).checked_sub(1), None);
279295
/// ```
296+
#[stable]
280297
fn checked_sub(self, other: Self) -> Option<Self>;
281298

282299
/// Checked integer multiplication. Computes `self * other`, returning
@@ -290,6 +307,7 @@ pub trait Int
290307
/// assert_eq!(5u8.checked_mul(51), Some(255));
291308
/// assert_eq!(5u8.checked_mul(52), None);
292309
/// ```
310+
#[stable]
293311
fn checked_mul(self, other: Self) -> Option<Self>;
294312

295313
/// Checked integer division. Computes `self / other`, returning `None` if
@@ -304,11 +322,12 @@ pub trait Int
304322
/// assert_eq!((-128i8).checked_div(-1), None);
305323
/// assert_eq!((1i8).checked_div(0), None);
306324
/// ```
307-
#[inline]
325+
#[stable]
308326
fn checked_div(self, other: Self) -> Option<Self>;
309327

310328
/// Saturating integer addition. Computes `self + other`, saturating at
311329
/// the numeric bounds instead of overflowing.
330+
#[stable]
312331
#[inline]
313332
fn saturating_add(self, other: Self) -> Self {
314333
match self.checked_add(other) {
@@ -320,6 +339,7 @@ pub trait Int
320339

321340
/// Saturating integer subtraction. Computes `self - other`, saturating at
322341
/// the numeric bounds instead of overflowing.
342+
#[stable]
323343
#[inline]
324344
fn saturating_sub(self, other: Self) -> Self {
325345
match self.checked_sub(other) {
@@ -338,6 +358,7 @@ pub trait Int
338358
///
339359
/// assert_eq!(2i.pow(4), 16);
340360
/// ```
361+
#[unstable = "pending integer conventions"]
341362
#[inline]
342363
fn pow(self, mut exp: uint) -> Self {
343364
let mut base = self;
@@ -369,7 +390,7 @@ macro_rules! uint_impl {
369390
$add_with_overflow:path,
370391
$sub_with_overflow:path,
371392
$mul_with_overflow:path) => {
372-
#[unstable = "trait is unstable"]
393+
#[stable]
373394
impl Int for $T {
374395
#[inline]
375396
fn zero() -> $T { 0 }
@@ -500,7 +521,7 @@ macro_rules! int_impl {
500521
$add_with_overflow:path,
501522
$sub_with_overflow:path,
502523
$mul_with_overflow:path) => {
503-
#[unstable = "trait is unstable"]
524+
#[stable]
504525
impl Int for $T {
505526
#[inline]
506527
fn zero() -> $T { 0 }
@@ -593,33 +614,38 @@ int_impl! { int = i64, u64, 64,
593614
intrinsics::i64_mul_with_overflow }
594615

595616
/// A built-in two's complement integer.
596-
#[unstable = "recently settled as part of numerics reform"]
617+
#[stable]
597618
pub trait SignedInt
598619
: Int
599620
+ Neg<Output=Self>
600621
{
601622
/// Computes the absolute value of `self`. `Int::min_value()` will be
602623
/// returned if the number is `Int::min_value()`.
624+
#[unstable = "overflow in debug builds?"]
603625
fn abs(self) -> Self;
604626

605627
/// Returns a number representing sign of `self`.
606628
///
607629
/// - `0` if the number is zero
608630
/// - `1` if the number is positive
609631
/// - `-1` if the number is negative
632+
#[stable]
610633
fn signum(self) -> Self;
611634

612635
/// Returns `true` if `self` is positive and `false` if the number
613636
/// is zero or negative.
637+
#[stable]
614638
fn is_positive(self) -> bool;
615639

616640
/// Returns `true` if `self` is negative and `false` if the number
617641
/// is zero or positive.
642+
#[stable]
618643
fn is_negative(self) -> bool;
619644
}
620645

621646
macro_rules! signed_int_impl {
622647
($T:ty) => {
648+
#[stable]
623649
impl SignedInt for $T {
624650
#[inline]
625651
fn abs(self) -> $T {
@@ -651,16 +677,18 @@ signed_int_impl! { i64 }
651677
signed_int_impl! { int }
652678

653679
/// A built-in unsigned integer.
654-
#[unstable = "recently settled as part of numerics reform"]
680+
#[stable]
655681
pub trait UnsignedInt: Int {
656682
/// Returns `true` iff `self == 2^k` for some `k`.
683+
#[stable]
657684
#[inline]
658685
fn is_power_of_two(self) -> bool {
659686
(self - Int::one()) & self == Int::zero() && !(self == Int::zero())
660687
}
661688

662689
/// Returns the smallest power of two greater than or equal to `self`.
663690
/// Unspecified behavior on overflow.
691+
#[stable]
664692
#[inline]
665693
fn next_power_of_two(self) -> Self {
666694
let bits = size_of::<Self>() * 8;
@@ -671,6 +699,7 @@ pub trait UnsignedInt: Int {
671699
/// Returns the smallest power of two greater than or equal to `n`. If the
672700
/// next power of two is greater than the type's maximum value, `None` is
673701
/// returned, otherwise the power of two is wrapped in `Some`.
702+
#[stable]
674703
fn checked_next_power_of_two(self) -> Option<Self> {
675704
let npot = self.next_power_of_two();
676705
if npot >= self {
@@ -681,19 +710,19 @@ pub trait UnsignedInt: Int {
681710
}
682711
}
683712

684-
#[unstable = "trait is unstable"]
713+
#[stable]
685714
impl UnsignedInt for uint {}
686715

687-
#[unstable = "trait is unstable"]
716+
#[stable]
688717
impl UnsignedInt for u8 {}
689718

690-
#[unstable = "trait is unstable"]
719+
#[stable]
691720
impl UnsignedInt for u16 {}
692721

693-
#[unstable = "trait is unstable"]
722+
#[stable]
694723
impl UnsignedInt for u32 {}
695724

696-
#[unstable = "trait is unstable"]
725+
#[stable]
697726
impl UnsignedInt for u64 {}
698727

699728
/// A generic trait for converting a value to a number.

0 commit comments

Comments
 (0)