]> git.lizzy.rs Git - rust.git/commit
core: Inherit the std::fmt module
authorAlex Crichton <alex@alexcrichton.com>
Sat, 10 May 2014 20:33:43 +0000 (13:33 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 16 May 2014 06:22:06 +0000 (23:22 -0700)
commitcf0619383d2ce0f7bd822f82cf487c7fa33d0b76
treed3b7cf19884affa54c0d22516d766007617e0893
parentba0a984a862f4f4246a3be014b9b244525bedd20
core: Inherit the std::fmt module

This commit moves all possible functionality from the standard library's string
formatting utilities into the core library. This is a breaking change, due to a
few tweaks in the semantics of formatting:

1. In order to break the dependency on the std::io module, a new trait,
   FormatWriter was introduced in core::fmt. This is the trait which is used
   (instead of Writer) to format data into a stream.
2. The new FormatWriter trait has one method, write(), which takes some bytes
   and can return an error, but the error contains very little information. The
   intent for this trait is for an adaptor writer to be used around the standard
   library's Writer trait.
3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but
   rather &mut FormatWriter. Since this trait is less common, all functions were
   removed except fmt::write, and it is not intended to be invoked directly.

The main API-breaking change here is that the fmt::Formatter structure will no
longer expose its `buf` field. All previous code writing directly to `f.buf`
using writer methods or the `write!` macro will now instead use `f` directly.

The Formatter object itself implements the `Writer` trait itself for
convenience, although it does not implement the `FormatWriter` trait. The
fallout of these changes will be in the following commits.

[breaking-change]
src/libcore/fmt/mod.rs [new file with mode: 0644]
src/libcore/fmt/num.rs [new file with mode: 0644]
src/libcore/fmt/rt.rs [new file with mode: 0644]
src/libcore/lib.rs
src/libstd/fmt.rs [new file with mode: 0644]
src/libstd/fmt/mod.rs [deleted file]
src/libstd/fmt/num.rs [deleted file]
src/libstd/fmt/rt.rs [deleted file]