about summary refs log tree commit diff
path: root/src/libstd/num
AgeCommit message (Collapse)AuthorLines
2014-09-23Deprecate `#[ignore(cfg(...))]`Steven Fackler-2/+2
Replace `#[ignore(cfg(a, b))]` with `#[cfg_attr(all(a, b), ignore)]`
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-2/+0
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-11/+11
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-06Use byte literals in libstdnham-19/+17
2014-07-23collections: Move push/pop to MutableSeqBrian Anderson-1/+1
Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude. Since the collections traits are in the prelude most consumers of these methods will continue to work without change. [breaking-change]
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-26/+26
[breaking-change]
2014-06-30libstd: set baseline stability levels.Aaron Turon-0/+6
Earlier commits have established a baseline of `experimental` stability for all crates under the facade (so their contents are considered experimental within libstd). Since `experimental` is `allow` by default, we should use the same baseline stability for libstd itself. This commit adds `experimental` tags to all of the modules defined in `std`, and `unstable` to `std` itself.
2014-06-24Test fixes from the rollupAlex Crichton-0/+4
Closes #14482 (std: Bring back half of Add on String) Closes #15026 (librustc: Remove the fallback to `int` from typechecking.) Closes #15119 (Add more description to c_str::unwrap().) Closes #15120 (Add tests for #12470 and #14285) Closes #15122 (Remove the cheat sheet.) Closes #15126 (rustc: Always include the morestack library) Closes #15127 (Improve ambiguous pronoun.) Closes #15130 (Fix #15129) Closes #15131 (Add the Guide, add warning to tutorial.) Closes #15134 (Xfailed tests for hygiene, etc.) Closes #15135 (core: Add stability attributes to Clone) Closes #15136 (Some minor improvements to core::bool) Closes #15137 (std: Add stability attributes to primitive numeric modules) Closes #15141 (Fix grammar in tutorial) Closes #15143 (Remove few FIXMEs) Closes #15145 (Avoid unnecessary temporary on assignments) Closes #15147 (Small improvements for metaprogramming) Closes #15153 (librustc: Check function argument patterns for legality of by-move) Closes #15154 (test: Add a test for regions, traits, and variance.) Closes #15159 (rustc: Don't register syntax crates twice) Closes #13816 (Stabilize version output for rustc and rustdoc)
2014-06-24std: Add stability attributes to primitive numeric modulesBrian Anderson-0/+23
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
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-15/+15
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-18Merge the Bitwise and ByteOrder traits into the Int traitBrendan Zabarauskas-1/+1
This reduces the complexity of the trait hierarchy.
2014-06-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-1/+1
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-06-08Fix spelling errors in comments.Joseph Crail-1/+1
2014-06-06Rename Iterator::len to countAaron Turon-1/+0
This commit carries out the request from issue #14678: > The method `Iterator::len()` is surprising, as all the other uses of > `len()` do not consume the value. `len()` would make more sense to be > called `count()`, but that would collide with the current > `Iterator::count(|T| -> bool) -> unit` method. That method, however, is > a bit redundant, and can be easily replaced with > `iter.filter(|x| x < 5).count()`. > After this change, we could then define the `len()` method > on `iter::ExactSize`. Closes #14678. [breaking-change]
2014-05-31rustdoc: Create anchor pages for primitive typesAlex Crichton-0/+22
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]` attribute. This attribute indicates that the current module is the "owner" of the primitive type `foo`. For rustdoc, this means that the doc-comment for the module is the doc-comment for the primitive type, plus a signal to all downstream crates that hyperlinks for primitive types will be directed at the crate containing the `#[doc]` directive. Additionally, rustdoc will favor crates closest to the one being documented which "implements the primitive type". For example, documentation of libcore links to libcore for primitive types, but documentation for libstd and beyond all links to libstd for primitive types. This change involves no compiler modifications, it is purely a rustdoc change. The landing pages for the primitive types primarily serve to show a list of implemented traits for the primitive type itself. The primitive types documented includes both strings and slices in a semi-ad-hoc way, but in a way that should provide at least somewhat meaningful documentation. Closes #14474
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-6/+6
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-29std: Recreate a `rand` moduleAlex Crichton-14/+14
This commit shuffles around some of the `rand` code, along with some reorganization. The new state of the world is as follows: * The librand crate now only depends on libcore. This interface is experimental. * The standard library has a new module, `std::rand`. This interface will eventually become stable. Unfortunately, this entailed more of a breaking change than just shuffling some names around. The following breaking changes were made to the rand library: * Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which will return an infinite stream of random values. Previous behavior can be regained with `rng.gen_iter().take(n).collect()` * Rng::gen_ascii_str() was removed. This has been replaced with Rng::gen_ascii_chars() which will return an infinite stream of random ascii characters. Similarly to gen_iter(), previous behavior can be emulated with `rng.gen_ascii_chars().take(n).collect()` * {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all relied on being able to use an OSRng for seeding, but this is no longer available in librand (where these types are defined). To retain the same functionality, these types now implement the `Rand` trait so they can be generated with a random seed from another random number generator. This allows the stdlib to use an OSRng to create seeded instances of these RNGs. * Rand implementations for `Box<T>` and `@T` were removed. These seemed to be pretty rare in the codebase, and it allows for librand to not depend on liballoc. Additionally, other pointer types like Rc<T> and Arc<T> were not supported. If this is undesirable, librand can depend on liballoc and regain these implementations. * The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`, but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice structure now has a lifetime associated with it. * The `sample` method on `Rng` has been moved to a top-level function in the `rand` module due to its dependence on `Vec`. cc #13851 [breaking-change]
2014-05-28std: Remove format_strbuf!()Alex Crichton-2/+2
This was only ever a transitionary macro.
2014-05-27std: Rename strbuf operations to stringRicho Healey-28/+28
[breaking-change]
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-35/+35
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-54/+67
2014-05-19Minor doc fixes in various placesPiotr Jawniak-1/+1
2014-05-15core: Update all tests for fmt movementAlex Crichton-12/+3
2014-05-15std: Fix float testsAlex Crichton-18/+18
2014-05-15std: Delegate some integer formatting to core::fmtAlex Crichton-44/+28
In an attempt to phase out the std::num::strconv module's string formatting functionality, this commit reimplements some provided methods for formatting integers on top of format!() instead of the custom (and slower) implementation inside of num::strconv. Primarily, this deprecates int_to_str_bytes_common
2014-05-15Updates with core::fmt changesAlex Crichton-3/+0
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15core: Move intrinsic float functionality from stdAlex Crichton-689/+8
The Float trait in libstd is quite a large trait which has dependencies on cmath (libm) and such, which libcore cannot satisfy. It also has many functions that libcore can implement, however, as LLVM has intrinsics or they're just bit twiddling. This commit moves what it can of the Float trait from the standard library into libcore to allow floats to be usable in the core library. The remaining functions are now resident in a FloatMath trait in the standard library (in the prelude now). Previous code which was generic over just the Float trait may now need to be generic over the FloatMath trait. [breaking-change]
2014-05-14Change StrBuf::from_utf8() to return ResultKevin Ballard-0/+1
This allows the original vector to be recovered in the event that it is not UTF-8. [breaking-change]
2014-05-11core: Remove the cast moduleAlex Crichton-9/+9
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-08Handle breakage after libcore splitKevin Ballard-21/+17
API Changes: - &[T] and ~[T] no longer support the addition operator (+)
2014-05-08Clean up unused importsKevin Ballard-1/+0
2014-05-08Handle fallout in std::ascii and std::strconvKevin Ballard-10/+10
API changes: - OwnedAsciiCast returns Vec<Ascii> instead of ~[Ascii] - OwnedAsciiCast is implemented on Vec<u8> - AsciiStr.to_lower/upper() returns Vec<Ascii> - IntoBytes::into_bytes() returns Vec<u8> - float_to_str_bytes_common() returns (Vec<u8>, bool)
2014-05-08More fallout from removing FromIterator on ~[T]Kevin Ballard-2/+2
A few methods in slice that used to return ~[T] now return Vec<T>: - VectorVector.concat/connect_vec() returns Vec<T> - slice::unzip() returns (Vec<T>, Vec<U>) - ImmutableCloneableVector.partitioned() returns (Vec<T>, Vec<T>) - OwnedVector.partition() returns (Vec<T>, Vec<T>)
2014-05-07core: Add unwrap()/unwrap_err() methods to ResultAlex Crichton-0/+3
These implementations must live in libstd right now because the fmt module has not been migrated yet. This will occur in a later PR. Just to be clear, there are new extension traits, but they are not necessary once the std::fmt module has migrated to libcore, which is a planned migration in the future.
2014-05-07core: Inherit the specific numeric modulesAlex Crichton-1506/+77
This implements all traits inside of core::num for all the primitive types, removing all the functionality from libstd. The std modules reexport all of the necessary items from the core modules.
2014-05-07core: Inherit what's possible from the num moduleAlex Crichton-849/+15
This strips out all string-related functionality from the num module. The inherited functionality is all that will be implemented in libcore (for now). Primarily, libcore will not implement the Float trait or any string-related functionality. It may be possible to migrate string parsing functionality into libcore in the future, but for now it will remain in libstd. All functionality in core::num is reexported in std::num.
2014-05-03Add lint check for negating uint literals and variables.Falco Hirschenberger-0/+7
See #11273 and #13318
2014-04-27Rewrote documentation for parse_bytes and to_str_bytes in {int, uint}_macros.rsJacob Hegna-10/+28
2014-04-24add min_pos_value constant for floatsAaron Turon-19/+40
Follow-up on issue #13297 and PR #13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
2014-04-23fix std::f32 and std::f64 constantsAaron Turon-75/+94
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrent, even when the values were correct. Closes #13297. Closes #11537.
2014-04-23auto merge of #13694 : jacob-hegna/rust/master, r=brsonbors-0/+20
... and uint_macros.rs
2014-04-22auto merge of #13597 : bjz/rust/float-api, r=brsonbors-429/+523
This pull request: - Merges the `Round` trait into the `Float` trait, continuing issue #10387. - Has floating point functions take their parameters by value. - Cleans up the formatting and organisation in the definition and implementations of the `Float` trait. More information on the breaking changes can be found in the commit messages.
2014-04-22Removed trailing whitespace in on line 242 in int_macros.rs and on line 156 ↵Jacob Hegna-3/+3
in uint_macros.rs
2014-04-22Added examples for parse_bytes(buf: &[u8], radix: uint) in int_macros.rs and ↵Jacob Hegna-0/+20
uint_macros.rs
2014-04-20auto merge of #13410 : alexcrichton/rust/issue-12278, r=pcwaltonbors-2/+8
This commit removes the compiler support for floating point modulus operations, as well as from the language. An implementation for this operator is now required to be provided by libraries. Floating point modulus is rarely used, doesn't exist in C, and is always lowered to an fmod library call by LLVM, and LLVM is considering removing support entirely. Closes #12278
2014-04-19auto merge of #13614 : cgaebel/rust/master, r=brsonbors-0/+6
We previously allocated 3x for every HashMap creation and resize. This patch reduces it to 1x.
2014-04-19Reorder Float methods in trait definition and make consistent in implsBrendan Zabarauskas-293/+268
2014-04-19Fix formatting in float implementationsBrendan Zabarauskas-72/+198
2014-04-19Have floating point functions take their parameters by value.Brendan Zabarauskas-154/+154
Make all of the methods in `std::num::Float` take `self` and their other parameters by value. Some of the `Float` methods took their parameters by value, and others took them by reference. This standardises them to one convention. The `Float` trait is intended for the built in IEEE 754 numbers only so we don't have to worry about the trait serving types of larger sizes. [breaking-change]