about summary refs log tree commit diff
path: root/src/libnum
AgeCommit message (Collapse)AuthorLines
2014-02-24Remove std::num::ToStrRadix from the preludeBrendan Zabarauskas-3/+3
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-0/+2
2014-02-24Move extra::json to libserializeAlex Crichton-2/+0
This also inverts the dependency between libserialize and libcollections. cc #8784
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-16/+20
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-2/+408
2014-02-20auto merge of #12343 : liigo/rust/move-extra-test-to-libtest, r=alexcrichtonbors-4/+4
I don't think `extra` is a good/meaningful name for a library. `libextra` should disappear, and we move all of its sub modules out of it. This PR is just one of that steps: move `extra::test` to `libtest`. I didn't add `libtest` to doc index, because it's an internal library currently. **Update:** All comments addressed. All tests passed. Rebased and squashed.
2014-02-20move extra::test to libtestLiigo Zhuang-4/+4
2014-02-19auto merge of #12392 : aepsil0n/rust/fix/pub_randbigint, r=huonwbors-1/+1
Closes #12383. Test suite did not capture this and can't as long as it is in the same module hierarchy. This is probably something that should be addressed in the future.
2014-02-19librustc: Remove unique vector patterns from the language.Patrick Walton-25/+18
Preparatory work for removing unique vectors from the language, which is itself preparatory work for dynamically sized types.
2014-02-19libnum: Make RandBigInt trait publicEduard Bopp-1/+1
Closes #12383.
2014-02-17Remove Real trait and move methods into FloatBrendan Zabarauskas-6/+6
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
2014-02-14extern mod => extern crateAlex Crichton-1/+1
This was previously implemented, and it just needed a snapshot to go through
2014-02-13Removed num::OrderableMichael Darakananda-65/+10
2014-02-13Remove a source of O(n^2) running time in bigints.Felix S. Klock II-2/+14
::num::bigint, Remove a source of O(n^2) running time in `fn shr_bits`. I'll cut to the chase: On my laptop, this brings the running time on `pidigits 2000` (from src/test/bench/shootout-pidigits.rs) from this: ``` % time ./pidigits 2000 > /dev/null real 0m7.695s user 0m7.690s sys 0m0.005s ``` to this: ``` % time ./pidigits 2000 > /dev/null real 0m0.322s user 0m0.318s sys 0m0.004s ``` The previous code was building up a vector by repeatedly making a fresh copy for each element that was unshifted onto the front, yielding quadratic running time. This fixes that by building up the vector in reverse order (pushing elements onto the end) and then reversing it. (Another option would be to build up a zero-initialized vector of the desired length and then installing all of the shifted result elements into their target index, but this was easier to hack up quickly, and yields the desired asymptotic improvement. I have been thinking of adding a `vec::from_fn_rev` to handle this case, maybe I will try that this weekend.)
2014-02-11Factoring bigint, rational, and complex out of libextra into libnum.Felix S. Klock II-0/+3704
Removed use of globs present in earlier versions of modules. Fix tutorial.md to reflect `extra::rational` ==> `num::rational`.