summary refs log tree commit diff
path: root/src/libstd/num/strconv.rs
AgeCommit message (Collapse)AuthorLines
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-25libstd: Document the following modules:Patrick Walton-20/+41
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-20rename std::vec -> std::sliceDaniel Micay-2/+2
Closes #12702
2014-02-28std: Avoid using "{:?}" in format stringsAlex Crichton-5/+5
This removes all usage of Poly in format strings from libstd. This doesn't prevent more future strings from coming in, but it at least removes the ones for now.
2014-02-21auto merge of #12382 : bjz/rust/fmt-int, r=alexcrichtonbors-17/+81
This is PR is the beginning of a complete rewrite and ultimate removal of the `std::num::strconv` module (see #6220), and the removal of the `ToStrRadix` trait in favour of using the `std::fmt` functionality directly. This should make for a cleaner API, encourage less allocation, and make the implementation more comprehensible . The `Formatter::{pad_integral, with_padding}` methods have also been refactored make things easier to understand. The formatting tests for integers have been moved out of `run-pass/ifmt.rs` in order to provide more immediate feedback when building using `make check-stage2-std NO_REBUILD=1`. Arbitrary radixes are now easier to use in format strings. For example: ~~~rust assert_eq!(format!("{:04}", radix(3, 2)), ~"0011"); ~~~ The benchmarks have been standardised between `std::num::strconv` and `std::num::fmt` to make it easier to compare the performance of the different implementations. ~~~ type | radix | std::num::strconv | std::num::fmt ======|=======|========================|====================== int | bin | 1748 ns/iter (+/- 150) | 321 ns/iter (+/- 25) int | oct | 706 ns/iter (+/- 53) | 179 ns/iter (+/- 22) int | dec | 640 ns/iter (+/- 59) | 207 ns/iter (+/- 10) int | hex | 637 ns/iter (+/- 77) | 205 ns/iter (+/- 19) int | 36 | 446 ns/iter (+/- 30) | 309 ns/iter (+/- 20) ------|-------|------------------------|---------------------- uint | bin | 1724 ns/iter (+/- 159) | 322 ns/iter (+/- 13) uint | oct | 663 ns/iter (+/- 25) | 175 ns/iter (+/- 7) uint | dec | 613 ns/iter (+/- 30) | 186 ns/iter (+/- 6) uint | hex | 519 ns/iter (+/- 44) | 207 ns/iter (+/- 20) uint | 36 | 418 ns/iter (+/- 16) | 308 ns/iter (+/- 32) ~~~
2014-02-22Decouple integer formatting from std::num::strconvBrendan Zabarauskas-17/+81
This works towards a complete rewrite and ultimate removal of the `std::num::strconv` module (see #6220), and the removal of the `ToStrRadix` trait in favour of using the `std::fmt` functionality directly. This should make for a cleaner API, encourage less allocation, and make the implementation far more comprehensible. The `Formatter::pad_integral` method has also been refactored make it easier to understand. The formatting tests for integers have been moved out of `run-pass/ifmt.rs` in order to provide more immediate feedback when building using `make check-stage2-std NO_REBUILD=1`. The benchmarks have been standardised between std::num::strconv and std::num::fmt to make it easier to compare the performance of the different implementations. Arbitrary radixes are now easier to use in format strings. For example: ~~~ assert_eq!(format!("{:04}", radix(3, 2)), ~"0011"); ~~~
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-14/+2
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-01-31Fix minor doc typosVirgile Andreani-2/+2
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-22float_to_str_bytes_common can now handle exponential notationSiegeLord-5/+65
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-1/+1
from_utf8_owned() behavior
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-1/+1
2014-01-18Replace old pow_with_uint with the new pow funcFlavio Percoco-6/+7
There was an old and barely used implementation of pow, which expected both parameters to be uint and required more traits to be implemented. Since a new implementation for `pow` landed, I'm proposing to remove this old impl in favor of the new one. The benchmark shows that the new implementation is faster than the one being removed: test num::bench::bench_pow_function ..bench: 9429 ns/iter (+/- 2055) test num::bench::bench_pow_with_uint_function ...bench: 28476 ns/iter (+/- 2202)
2014-01-07std: Fill in all missing importsAlex Crichton-1/+1
Fallout from the previous commits
2014-01-06Remove some unnecessary type castsFlorian Hahn-1/+1
Conflicts: src/librustc/middle/lint.rs
2013-12-04std::str: remove from_utf8.Huon Wilson-1/+1
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-4/+4
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-3/+13
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-5/+5
Who doesn't like a massive renaming?
2013-10-02std: Replace num::IntConvertible with {To,From}PrimitiveErick Tryzelaar-13/+13
2013-10-02auto merge of #9665 : alexcrichton/rust/snapshot, r=brsonbors-1/+1
Uses the new snapshots to kill the old `loop` and introduce the new `continue`.
2013-10-01Migrate users of 'loop' to 'continue'Alex Crichton-1/+1
Closes #9467
2013-10-01remove the `float` typeDaniel Micay-3/+2
It is simply defined as `f64` across every platform right now. A use case hasn't been presented for a `float` type defined as the highest precision floating point type implemented in hardware on the platform. Performance-wise, using the smallest precision correct for the use case greatly saves on cache space and allows for fitting more numbers into SSE/AVX registers. If there was a use case, this could be implemented as simply a type alias or a struct thanks to `#[cfg(...)]`. Closes #6592 The mailing list thread, for reference: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-09-30std: Remove usage of fmt!Alex Crichton-5/+5
2013-09-23std: merge rand::{Rng,RngUtil} with default methods.Huon Wilson-1/+1
Also, documentation & general clean-up: - remove `gen_char_from`: better served by `sample` or `choose`. - `gen_bytes` generalised to `gen_vec`. - `gen_int_range`/`gen_uint_range` merged into `gen_integer_range` and made to be properly uniformly distributed. Fixes #8644. Minor adjustments to other functions.
2013-09-19Rename the NaN and is_NaN methods to lowercase.Chris Morgan-4/+4
This is for consistency in naming conventions. - ``std::num::Float::NaN()`` is changed to ``nan()``; - ``std::num::Float.is_NaN()`` is changed to ``is_nan()``; and - ``std::num::strconv::NumStrConv::NaN()`` is changed to ``nan()``. Fixes #9319.
2013-09-06auto merge of #9010 : aaronlaursen/rust/master, r=alexcrichtonbors-4/+31
Here's a fix for issue #7588, "Overflow handling of from_str methods is broken". The integer overflow issues are taken care of by checking to see if the multiply-by-radix-and-add-next-digit process is reversible. If it overflowed, then some information is lost and the process is irreversible, in which case, None is returned. Floats now consistently return Some(Inf) of Some(-Inf) on overflow thanks to a call to NumStrConv::inf() and NumStrConv::neg_inf() respectively when the overflow is detected (which yields a value of None in the case of ints and uints anyway). This is my first contribution to Rust, and my first time using the language in general, so any and all feedback is appreciated.
2013-09-06fix for issue #7588, overflow now handled correctlyAaron Laursen-4/+31
2013-09-05Rename str::from_bytes to str::from_utf8, closes #8985Florian Hahn-1/+1
2013-08-20rm obsolete integer to_str{,_radix} free functionsDaniel Micay-2/+2
2013-08-07Forbid `priv` where it has no effectAlex Crichton-3/+3
This is everywhere except struct fields and enum variants.
2013-08-05Updated std::Option, std::Either and std::ResultMarvin Löbel-1/+1
- Made naming schemes consistent between Option, Result and Either - Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None) - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-07-22std: add #[bench] benchmarks for num::strconvGraydon Hoare-0/+24
2013-07-19std: Remove old magic core modBrian Anderson-1/+1
2013-07-17librustc: Remove all uses of the `Copy` bound.Patrick Walton-4/+3
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-9/+10
2013-07-01rustc: add a lint to enforce uppercase statics.Huon Wilson-7/+7
2013-06-30auto merge of #7487 : huonw/rust/vec-kill, r=cmrbors-3/+2
Continuation of #7430. I haven't removed the `map` method, since the replacement `v.iter().transform(f).collect::<~[SomeType]>()` is a little ridiculous at the moment.
2013-06-30Specialize to_str_common for floats/integers in strconvAlex Crichton-83/+113
This allows the integral paths to avoid allocations on the heap Closes #4424, #4423
2013-06-30Convert vec::{reverse, swap} to methods.Huon Wilson-3/+2
2013-06-18replace #[inline(always)] with #[inline]. r=burningtree.Graydon Hoare-18/+18
2013-06-16Add copies to type params with Copy boundNiko Matsakis-14/+14
2013-06-12std: unify the str -> [u8] functions as 3 methods: .as_bytes() and ↵Huon Wilson-6/+7
.as_bytes_with_null[_consume](). The first acts on &str and is not nul-terminated, the last two act on strings that are always null terminated (&'static str, ~str and @str).
2013-05-30Require documentation by default for libstdAlex Crichton-0/+2
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-0/+673
This only changes the directory names; it does not change the "real" metadata names.