Skip to content

Commit 808b848

Browse files
brsonalexcrichton
authored andcommitted
std: Add stability attributes to primitive numeric modules
The following are unstable: - core::int, i8, i16, i32, i64 - core::uint, u8, u16, u32, u64 - core::int::{BITS, BYTES, MIN, MAX}, etc. - std::int, i8, i16, i32, i64 - std::uint, u8, u16, u32, u64 The following are experimental: - std::from_str::FromStr and impls - may need to return Result instead of Option - std::int::parse_bytes, etc. - ditto - std::num::FromStrRadix and impls - ditto - std::num::from_str_radix - ditto The following are deprecated: - std::num::ToStrRadix and imples - Wrapper around fmt::radix. Wrong name (Str vs String) See https://github.com/rust-lang/rust/wiki/Meeting-API-review-2014-06-23#uint
1 parent 250e236 commit 808b848

27 files changed

+44
-0
lines changed

src/libcore/num/i16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 16-bits integers (`i16` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i16")]
1415

1516
int_module!(i16, 16)

src/libcore/num/i32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 32-bits integers (`i32` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i32")]
1415

1516
int_module!(i32, 32)

src/libcore/num/i64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 64-bits integers (`i64` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i64")]
1415

1516
int_module!(i64, 64)

src/libcore/num/i8.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 8-bits integers (`i8` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i8")]
1415

1516
int_module!(i8, 8)

src/libcore/num/int.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for architecture-sized signed integers (`int` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "int")]
1415

1516
#[cfg(target_word_size = "32")] int_module!(int, 32)

src/libcore/num/int_macros.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ macro_rules! int_module (($T:ty, $bits:expr) => (
1515

1616
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
1717
// calling the `mem::size_of` function.
18+
#[unstable]
1819
pub static BITS : uint = $bits;
1920
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
2021
// calling the `mem::size_of` function.
22+
#[unstable]
2123
pub static BYTES : uint = ($bits / 8);
2224

2325
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
2426
// calling the `Bounded::min_value` function.
27+
#[unstable]
2528
pub static MIN: $T = (-1 as $T) << (BITS - 1);
2629
// FIXME(#9837): Compute MIN like this so the high bits that shouldn't exist are 0.
2730
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
2831
// calling the `Bounded::max_value` function.
32+
#[unstable]
2933
pub static MAX: $T = !MIN;
3034

3135
#[cfg(test)]

src/libcore/num/u16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 16-bits integers (`u16` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u16")]
1415

1516
uint_module!(u16, i16, 16)

src/libcore/num/u32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 32-bits integers (`u32` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u32")]
1415

1516
uint_module!(u32, i32, 32)

src/libcore/num/u64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 64-bits integer (`u64` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u64")]
1415

1516
uint_module!(u64, i64, 64)

src/libcore/num/u8.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 8-bits integers (`u8` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u8")]
1415

1516
uint_module!(u8, i8, 8)

src/libcore/num/uint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for architecture-sized unsigned integers (`uint` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "uint")]
1415

1516
uint_module!(uint, int, ::int::BITS)

src/libcore/num/uint_macros.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (
1515

16+
#[unstable]
1617
pub static BITS : uint = $bits;
18+
#[unstable]
1719
pub static BYTES : uint = ($bits / 8);
1820

21+
#[unstable]
1922
pub static MIN: $T = 0 as $T;
23+
#[unstable]
2024
pub static MAX: $T = 0 as $T - 1 as $T;
2125

2226
#[cfg(test)]

src/libnum/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
html_root_url = "http://doc.rust-lang.org/",
5555
html_playground_url = "http://play.rust-lang.org/")]
5656

57+
#![allow(deprecated)] // from_str_radix
58+
5759
extern crate rand;
5860

5961
pub use bigint::{BigInt, BigUint};

src/libstd/from_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use str::StrAllocating;
1616

1717
/// A trait to abstract the idea of creating a new instance of a type from a
1818
/// string.
19+
#[experimental = "might need to return Result"]
1920
pub trait FromStr {
2021
/// Parses a string `s` to return an optional value of this type. If the
2122
/// string is ill-formatted, the None is returned.

src/libstd/num/i16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 16-bits integers (`i16` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i16")]
1415

1516
use from_str::FromStr;

src/libstd/num/i32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 32-bits integers (`i32` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i32")]
1415

1516
use from_str::FromStr;

src/libstd/num/i64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 64-bits integers (`i64` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i64")]
1415

1516
use from_str::FromStr;

src/libstd/num/i8.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for signed 8-bits integers (`i8` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "i8")]
1415

1516
use from_str::FromStr;

src/libstd/num/int.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for architecture-sized signed integers (`int` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "int")]
1415

1516
use from_str::FromStr;

src/libstd/num/int_macros.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ macro_rules! int_module (($T:ty) => (
2626
/// assert!(num == Some(123456789));
2727
/// ```
2828
#[inline]
29+
#[experimental = "might need to return Result"]
2930
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> {
3031
strconv::from_str_bytes_common(buf, radix, true, false, false,
3132
strconv::ExpNone, false, false)
3233
}
3334

35+
#[experimental = "might need to return Result"]
3436
impl FromStr for $T {
3537
#[inline]
3638
fn from_str(s: &str) -> Option<$T> {
@@ -39,6 +41,7 @@ impl FromStr for $T {
3941
}
4042
}
4143

44+
#[experimental = "might need to return Result"]
4245
impl FromStrRadix for $T {
4346
#[inline]
4447
fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
@@ -61,6 +64,7 @@ impl FromStrRadix for $T {
6164
/// });
6265
/// ```
6366
#[inline]
67+
#[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"]
6468
pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
6569
use io::{Writer, Seek};
6670
// The radix can be as low as 2, so we need at least 64 characters for a
@@ -74,6 +78,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
7478
f(buf.slice(0, amt))
7579
}
7680

81+
#[deprecated = "use fmt::radix"]
7782
impl ToStrRadix for $T {
7883
/// Convert to a string in a given base.
7984
#[inline]

src/libstd/num/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,19 @@ pub trait FloatMath: Float {
111111
}
112112

113113
/// A generic trait for converting a value to a string with a radix (base)
114+
#[deprecated = "use fmt::radix"]
114115
pub trait ToStrRadix {
115116
fn to_str_radix(&self, radix: uint) -> String;
116117
}
117118

118119
/// A generic trait for converting a string with a radix (base) to a value
120+
#[experimental = "might need to return Result"]
119121
pub trait FromStrRadix {
120122
fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
121123
}
122124

123125
/// A utility function that just calls FromStrRadix::from_str_radix.
126+
#[experimental = "might need to return Result"]
124127
pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: uint) -> Option<T> {
125128
FromStrRadix::from_str_radix(str, radix)
126129
}

src/libstd/num/u16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 16-bits integers (`u16` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u16")]
1415

1516
use from_str::FromStr;

src/libstd/num/u32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 32-bits integers (`u32` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u32")]
1415

1516
use from_str::FromStr;

src/libstd/num/u64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 64-bits integer (`u64` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u64")]
1415

1516
use from_str::FromStr;

src/libstd/num/u8.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for unsigned 8-bits integers (`u8` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "u8")]
1415

1516
use from_str::FromStr;

src/libstd/num/uint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Operations and constants for architecture-sized unsigned integers (`uint` type)
1212
13+
#![unstable]
1314
#![doc(primitive = "uint")]
1415

1516
use from_str::FromStr;

src/libstd/num/uint_macros.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ macro_rules! uint_module (($T:ty) => (
2727
/// assert!(num == Some(123456789));
2828
/// ```
2929
#[inline]
30+
#[experimental = "might need to return Result"]
3031
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> {
3132
strconv::from_str_bytes_common(buf, radix, false, false, false,
3233
strconv::ExpNone, false, false)
3334
}
3435

36+
#[experimental = "might need to return Result"]
3537
impl FromStr for $T {
3638
#[inline]
3739
fn from_str(s: &str) -> Option<$T> {
@@ -40,6 +42,7 @@ impl FromStr for $T {
4042
}
4143
}
4244

45+
#[experimental = "might need to return Result"]
4346
impl FromStrRadix for $T {
4447
#[inline]
4548
fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
@@ -62,6 +65,7 @@ impl FromStrRadix for $T {
6265
/// });
6366
/// ```
6467
#[inline]
68+
#[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"]
6569
pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
6670
use io::{Writer, Seek};
6771
// The radix can be as low as 2, so we need at least 64 characters for a
@@ -75,6 +79,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
7579
f(buf.slice(0, amt))
7680
}
7781

82+
#[deprecated = "use fmt::radix"]
7883
impl ToStrRadix for $T {
7984
/// Convert to a string in a given base.
8085
#[inline]

0 commit comments

Comments
 (0)