summary refs log tree commit diff
path: root/src/libstd/num
AgeCommit message (Collapse)AuthorLines
2014-12-23Rename and namespace `FPCategory`Tobias Bucher-21/+23
Rename `FPCategory` to `FpCategory` and `Fp* to `*` in order to adhere to the naming convention This is a [breaking-change]. Existing code like this: ``` use std::num::{FPCategory, FPNaN}; ``` should be adjusted to this: ``` use std::num::FpCategory as Fp ``` In the following code you can use the constants `Fp::Nan`, `Fp::Normal`, etc.
2014-12-21Fallout of std::str stabilizationAlex Crichton-1/+1
2014-12-21rollup merge of #20062: aturon/stab-2-intsAlex Crichton-2/+2
This small patch stabilizes the names of all integer modules (including `int` and `uint`) and the `MIN` and `MAX` constants. The `BITS` and `BYTES` constants are left unstable for now. r? @alexcrichton
2014-12-21Remove a ton of public reexportsCorey Farwell-19/+23
Remove most of the public reexports mentioned in #19253 These are all leftovers from the enum namespacing transition In particular: * src/libstd/num/strconv.rs * ExponentFormat * SignificantDigits * SignFormat * src/libstd/path/windows.rs * PathPrefix * src/libstd/sys/windows/timer.rs * Req * src/libcollections/str.rs * MaybeOwned * src/libstd/collections/hash/map.rs * Entry * src/libstd/collections/hash/table.rs * BucketState * src/libstd/dynamic_lib.rs * Rtld * src/libstd/io/net/ip.rs * IpAddr * src/libstd/os.rs * MemoryMapKind * MapOption * MapError * src/libstd/sys/common/net.rs * SocketStatus * InAddr * src/libstd/sys/unix/timer.rs * Req [breaking-change]
2014-12-19Stabilize integer modulesAaron Turon-2/+2
This small patch stabilizes the names of all integer modules (including `int` and `uint`) and the `MIN` and `MAX` constants. The `BITS` and `BYTES` constants are left unstable for now.
2014-12-20Fix fallout of removing import_shadowing in tests.Eduard Burtescu-6/+4
2014-12-20auto merge of #19640 : aliblong/rust/power_of_two_reform, r=Gankrobors-5/+26
The `is_power_of_two()` method of the `UnsignedInt` trait currently returns `true` for `self == 0`. Zero is not a power of two, assuming an integral exponent `k >= 0`. I've therefore moved this functionality to the new method `is_power_of_two_or_zero()` and reformed `is_power_of_two()` to return false for `self == 0`. To illustrate the usefulness of the existence of both functions, consider `HashMap`. Its capacity must be zero or a power of two; conversely, it also requires a (non-zero) power of two for key and val alignment. Also, added a small amount of documentation regarding #18604.
2014-12-19Reform power_of_two methods for perf increase & semantic change to consider ↵Aaron Liblong-5/+26
0 not a power of 2. Vec panics when attempting to reserve capacity > int::MAX (uint::MAX / 2).
2014-12-19libstd: use `#[deriving(Copy)]`Jorge Aparicio-7/+3
2014-12-18librustc: Always parse `macro!()`/`macro![]` as expressions if notPatrick Walton-38/+38
followed by a semicolon. This allows code like `vec![1i, 2, 3].len();` to work. This breaks code that uses macros as statements without putting semicolons after them, such as: fn main() { ... assert!(a == b) assert!(c == d) println(...); } It also breaks code that uses macros as items without semicolons: local_data_key!(foo) fn main() { println("hello world") } Add semicolons to fix this code. Those two examples can be fixed as follows: fn main() { ... assert!(a == b); assert!(c == d); println(...); } local_data_key!(foo); fn main() { println("hello world") } RFC #378. Closes #18635. [breaking-change]
2014-12-16auto merge of #19747 : alexcrichton/rust/slice-one-trait, r=brsonbors-5/+3
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-14std: Collapse SlicePrelude traitsAlex Crichton-5/+3
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-13libstd: fix unit testsJorge Aparicio-11/+13
2014-12-13libstd: use unboxed closuresJorge Aparicio-2/+18
2014-12-09Rollback accidental documentation changesTobias Bucher-29/+21
These probably happened during the merge of the commit that made `Copy` opt-in. Also, convert the last occurence of `/**` to `///` in `src/libstd/num/strconv.rs`
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-19/+32
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-06libstd: remove unnecessary `to_string()` callsJorge Aparicio-16/+16
2014-11-27Documentation fix for std::num::strconvBarosl Lee-41/+35
- int_to_str_bytes_common() doesn't have a return value. - float_to_str_bytes_common() has an old-style doc comment.
2014-11-25/** -> ///Steve Klabnik-25/+26
This is considered good convention.
2014-11-21Fix various deprecation warnings from char changesBrian Anderson-1/+2
2014-11-18libs: stabilize most numerics after RFC changesAaron Turon-11/+29
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]
2014-11-18auto merge of #19031 : nodakai/rust/libcore-pow-and-sq, r=bjzbors-3/+3
[breaking-change] Deprecates `core::num::pow` in favor of `Int::pow`.
2014-11-18libcore: add num::Int::pow() and deprecate num::pow().NODA, Kai-3/+3
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-11-17Switch to purely namespaced enumsSteven Fackler-0/+4
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17Fix fallout from coercion removalNick Cameron-1/+1
2014-11-16Move ToString to collections::stringBrendan Zabarauskas-1/+1
This also impls `FormatWriter` for `Vec<u8>`
2014-11-16Remove use of deprecated functionBrendan Zabarauskas-2/+3
2014-11-16Move FromStr to core::strBrendan Zabarauskas-562/+22
2014-11-14auto merge of #18880 : barosl/rust/doc-fail-to-panic, r=alexcrichtonbors-6/+6
I found some occurrences of "failure" and "fails" in the documentation. I changed them to "panics" if it means a task panic. Otherwise I left it as is, or changed it to "errors" to clearly distinguish them. Also, I made a minor fix that is breaking the layout of a module page. "Example" is shown in an irrelevant place from the following page: http://doc.rust-lang.org/std/os/index.html
2014-11-13Remove Signed trait and add SignedInt traitBrendan Zabarauskas-2/+2
The methods have been moved into Float and SignedInt
2014-11-13Remove lots of numeric traits from the preludesBrendan Zabarauskas-1/+10
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
2014-11-13Deprecate Num, Unsigned and PrimitiveBrendan Zabarauskas-2/+2
2014-11-13Deprecate Zero and One traitsBrendan Zabarauskas-16/+13
2014-11-13Deprecate Bounded traitBrendan Zabarauskas-3/+2
2014-11-13Move checked arithmetic operators into Int traitBrendan Zabarauskas-26/+25
2014-11-13Move saturating operator methods into IntBrendan Zabarauskas-1/+1
2014-11-13Create UnsignedInt trait and deprecate free functionsBrendan Zabarauskas-8/+8
2014-11-13Move abs_sub to FloatMathBrendan Zabarauskas-1/+23
This removes the need for libcore to depend on libm. `abs_sub` is not as useful for integers.
2014-11-13Take parameters by-value in Signed traitBrendan Zabarauskas-20/+20
2014-11-12Fix remaining documentation to reflect fail!() -> panic!()Barosl Lee-6/+6
Throughout the docs, "failure" was replaced with "panics" if it means a task panic. Otherwise, it remained as is, or changed to "errors" to clearly differentiate it from a task panic.
2014-11-07Fixing #18659juxiliary-1/+17
Changes the radix multiplier to start at -0.0 instead of -1.0 when reading strings that start with '-'.
2014-11-06Prelude: rename and consolidate extension traitsAaron Turon-2/+2
This commit renames a number of extension traits for slices and string slices, now that they have been refactored for DST. In many cases, multiple extension traits could now be consolidated. Further consolidation will be possible with generalized where clauses. The renamings are consistent with the [new `-Prelude` suffix](https://github.com/rust-lang/rfcs/pull/344). There are probably a few more candidates for being renamed this way, but that is left for API stabilization of the relevant modules. Because this renames traits, it is a: [breaking-change] However, I do not expect any code that currently uses the standard library to actually break. Closes #17917
2014-11-04Deprecate {f32, f64}::from_str_hexBrendan Zabarauskas-80/+27
This is now covered by `FromStrRadix::from_str_radix`
2014-11-04Simplify float string conversion function furtherBrendan Zabarauskas-161/+115
We now have a really simple function signature: pub fn from_str_radix_float<T: Float>(src: &str, radix: uint) -> Option<T> By removing some of the arguments, we remove the possibility of some invalid states.
2014-11-04Clean up from_str_float and use iteratorsBrendan Zabarauskas-156/+125
2014-11-04Remove unnecessary features from strconvBrendan Zabarauskas-121/+33
2014-11-04Separate string->integer implementation in strconvBrendan Zabarauskas-181/+131
2014-11-01collections: Remove all collections traitsAlex Crichton-1/+0
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
2014-10-30rollup merge of #18445 : alexcrichton/index-mutAlex Crichton-2/+2
Conflicts: src/libcollections/vec.rs
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-6/+6
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs