]> git.lizzy.rs Git - rust.git/commit
Decouple integer formatting from std::num::strconv
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Fri, 21 Feb 2014 16:52:32 +0000 (03:52 +1100)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Fri, 21 Feb 2014 16:56:16 +0000 (03:56 +1100)
commite37327bfee6217e46921a294f1a321e2d71300ca
treebf179a6d7d458f18e4a78becd67a70cf6fe9079b
parent9abff54d61babab8050c108f7cb6b957b1636337
Decouple integer formatting from std::num::strconv

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");
~~~
src/libstd/fmt/mod.rs
src/libstd/fmt/num.rs [new file with mode: 0644]
src/libstd/num/mod.rs
src/libstd/num/strconv.rs
src/test/run-pass/ifmt.rs