libs: stabilize most numerics after RFC changes
This commit adds stability markers for the APIs that have recently been aligned with [numerics reform](https://github.com/rust-lang/rfcs/pull/369). For APIs that were changed as part of that reform, `#[unstable]` is used to reflect the recency, but the APIs will become `#[stable]` in a follow-up pass. In addition, a few aspects of the APIs not explicitly covered by the RFC are marked here -- in particular, constants for floats. This commit does not mark the `uint` or `int` modules as `#[stable]`, given the ongoing debate out the names and roles of these types. Due to some deprecation (see the RFC for details), this is a: [breaking-change]
This commit is contained in:
parent
e09d98603e
commit
bdbc09ad48
22 changed files with 122 additions and 34 deletions
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for 32-bits floats (`f32` type)
|
||||
|
||||
#![experimental]
|
||||
#![stable]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(unsigned_negation)]
|
||||
#![doc(primitive = "f32")]
|
||||
|
|
@ -68,6 +68,7 @@ mod cmath {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl FloatMath for f32 {
|
||||
/// Constructs a floating point number by multiplying `x` by 2 raised to the
|
||||
/// power of `exp`
|
||||
|
|
@ -248,6 +249,7 @@ impl FloatMath for f32 {
|
|||
///
|
||||
/// * num - The float value
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_string(num: f32) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
|
||||
|
|
@ -260,6 +262,7 @@ pub fn to_string(num: f32) -> String {
|
|||
///
|
||||
/// * num - The float value
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_hex(num: f32) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 16u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
|
||||
|
|
@ -274,6 +277,7 @@ pub fn to_str_hex(num: f32) -> String {
|
|||
/// * num - The float value
|
||||
/// * radix - The base to use
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
|
||||
strconv::float_to_str_common(num, rdx, true,
|
||||
strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false)
|
||||
|
|
@ -287,6 +291,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
|
|||
/// * num - The float value
|
||||
/// * digits - The number of significant digits
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exact(num: f32, dig: uint) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpNone, false);
|
||||
|
|
@ -301,6 +306,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String {
|
|||
/// * num - The float value
|
||||
/// * digits - The number of significant digits
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_digits(num: f32, dig: uint) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpNone, false);
|
||||
|
|
@ -316,6 +322,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String {
|
|||
/// * digits - The number of digits after the decimal point
|
||||
/// * upper - Use `E` instead of `e` for the exponent sign
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpDec, upper);
|
||||
|
|
@ -331,6 +338,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
|
|||
/// * digits - The number of digits after the decimal point
|
||||
/// * upper - Use `E` instead of `e` for the exponent sign
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpDec, upper);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for 64-bits floats (`f64` type)
|
||||
|
||||
#![experimental]
|
||||
#![stable]
|
||||
#![allow(missing_docs)]
|
||||
#![doc(primitive = "f64")]
|
||||
|
||||
|
|
@ -76,6 +76,7 @@ mod cmath {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl FloatMath for f64 {
|
||||
/// Constructs a floating point number by multiplying `x` by 2 raised to the
|
||||
/// power of `exp`
|
||||
|
|
@ -256,6 +257,7 @@ impl FloatMath for f64 {
|
|||
///
|
||||
/// * num - The float value
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_string(num: f64) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
|
||||
|
|
@ -268,6 +270,7 @@ pub fn to_string(num: f64) -> String {
|
|||
///
|
||||
/// * num - The float value
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_hex(num: f64) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 16u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false);
|
||||
|
|
@ -282,6 +285,7 @@ pub fn to_str_hex(num: f64) -> String {
|
|||
/// * num - The float value
|
||||
/// * radix - The base to use
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
|
||||
strconv::float_to_str_common(num, rdx, true,
|
||||
strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false)
|
||||
|
|
@ -295,6 +299,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
|
|||
/// * num - The float value
|
||||
/// * digits - The number of significant digits
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exact(num: f64, dig: uint) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpNone, false);
|
||||
|
|
@ -309,6 +314,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String {
|
|||
/// * num - The float value
|
||||
/// * digits - The number of significant digits
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_digits(num: f64, dig: uint) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpNone, false);
|
||||
|
|
@ -324,6 +330,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String {
|
|||
/// * digits - The number of digits after the decimal point
|
||||
/// * upper - Use `E` instead of `e` for the exponent sign
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigExact(dig), strconv::ExpDec, upper);
|
||||
|
|
@ -339,6 +346,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
|
|||
/// * digits - The number of digits after the decimal point
|
||||
/// * upper - Use `E` instead of `e` for the exponent sign
|
||||
#[inline]
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
|
||||
let (r, _) = strconv::float_to_str_common(
|
||||
num, 10u, true, strconv::SignNeg, strconv::DigMax(dig), strconv::ExpDec, upper);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for signed 16-bits integers (`i16` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "i16")]
|
||||
|
||||
pub use core::i16::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for signed 32-bits integers (`i32` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "i32")]
|
||||
|
||||
pub use core::i32::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for signed 64-bits integers (`i64` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "i64")]
|
||||
|
||||
pub use core::i64::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for signed 8-bits integers (`i8` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "i8")]
|
||||
|
||||
pub use core::i8::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//! These are implemented for the primitive numeric types in `std::{u8, u16,
|
||||
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
|
||||
|
||||
#![experimental]
|
||||
#![stable]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
#[cfg(test)] use cmp::PartialEq;
|
||||
|
|
@ -33,9 +33,11 @@ pub use core::num::{FromStrRadix, from_str_radix};
|
|||
pub use core::num::{FPCategory, FPNaN, FPInfinite, FPZero, FPSubnormal};
|
||||
pub use core::num::{FPNormal, Float};
|
||||
|
||||
#[experimental = "may be removed or relocated"]
|
||||
pub mod strconv;
|
||||
|
||||
/// Mathematical operations on primitive floating point numbers.
|
||||
#[unstable = "may be altered to inline the Float trait"]
|
||||
pub trait FloatMath: Float {
|
||||
/// Constructs a floating point number created by multiplying `x` by 2
|
||||
/// raised to the power of `exp`.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for unsigned 16-bits integers (`u16` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "u16")]
|
||||
|
||||
pub use core::u16::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for unsigned 32-bits integers (`u32` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "u32")]
|
||||
|
||||
pub use core::u32::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for unsigned 64-bits integer (`u64` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "u64")]
|
||||
|
||||
pub use core::u64::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
//! Operations and constants for unsigned 8-bits integers (`u8` type)
|
||||
|
||||
#![unstable]
|
||||
#![stable]
|
||||
#![doc(primitive = "u8")]
|
||||
|
||||
pub use core::u8::{BITS, BYTES, MIN, MAX};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue