auto merge of #18827 : bjz/rust/rfc369-numerics, r=alexcrichton
This implements a considerable portion of rust-lang/rfcs#369 (tracked in #18640). Some interpretations had to be made in order to get this to work. The breaking changes are listed below: [breaking-change] - `core::num::{Num, Unsigned, Primitive}` have been deprecated and their re-exports removed from the `{std, core}::prelude`. - `core::num::{Zero, One, Bounded}` have been deprecated. Use the static methods on `core::num::{Float, Int}` instead. There is no equivalent to `Zero::is_zero`. Use `(==)` with `{Float, Int}::zero` instead. - `Signed::abs_sub` has been moved to `std::num::FloatMath`, and is no longer implemented for signed integers. - `core::num::Signed` has been removed, and its methods have been moved to `core::num::Float` and a new trait, `core::num::SignedInt`. The methods now take the `self` parameter by value. - `core::num::{Saturating, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}` have been removed, and their methods moved to `core::num::Int`. Their parameters are now taken by value. This means that - `std::time::Duration` no longer implements `core::num::{Zero, CheckedAdd, CheckedSub}` instead defining the required methods non-polymorphically. - `core::num::{zero, one, abs, signum}` have been deprecated. Use their respective methods instead. - The `core::num::{next_power_of_two, is_power_of_two, checked_next_power_of_two}` functions have been deprecated in favor of methods defined a new trait, `core::num::UnsignedInt` - `core::iter::{AdditiveIterator, MultiplicativeIterator}` are now only implemented for the built-in numeric types. - `core::iter::{range, range_inclusive, range_step, range_step_inclusive}` now require `core::num::Int` to be implemented for the type they a re parametrized over.
This commit is contained in:
commit
6f7081fad5
77 changed files with 1136 additions and 1035 deletions
|
@ -199,7 +199,7 @@ use std::collections::{HashMap, TreeMap};
|
|||
use std::{char, f64, fmt, io, num, str};
|
||||
use std::io::MemWriter;
|
||||
use std::mem::{swap, transmute};
|
||||
use std::num::{FPNaN, FPInfinite};
|
||||
use std::num::{Float, FPNaN, FPInfinite, Int};
|
||||
use std::str::ScalarValue;
|
||||
use std::string;
|
||||
use std::vec::Vec;
|
||||
|
@ -609,7 +609,7 @@ impl<'a> PrettyEncoder<'a> {
|
|||
/// This is safe to set during encoding.
|
||||
pub fn set_indent<'a>(&mut self, indent: uint) {
|
||||
// self.indent very well could be 0 so we need to use checked division.
|
||||
let level = self.curr_indent.checked_div(&self.indent).unwrap_or(0);
|
||||
let level = self.curr_indent.checked_div(self.indent).unwrap_or(0);
|
||||
self.indent = indent;
|
||||
self.curr_indent = level * self.indent;
|
||||
}
|
||||
|
@ -1484,7 +1484,7 @@ impl<T: Iterator<char>> Parser<T> {
|
|||
}
|
||||
}
|
||||
|
||||
let exp = num::pow(10_f64, exp);
|
||||
let exp = 10_f64.powi(exp as i32);
|
||||
if neg_exp {
|
||||
res /= exp;
|
||||
} else {
|
||||
|
@ -2417,6 +2417,7 @@ mod tests {
|
|||
TrailingCharacters, TrailingComma};
|
||||
use std::{i64, u64, f32, f64, io};
|
||||
use std::collections::TreeMap;
|
||||
use std::num::Float;
|
||||
use std::string;
|
||||
|
||||
#[deriving(Decodable, Eq, PartialEq, Show)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue