提交 8767093e 编写于 作者: A Alex Crichton

std: Rewrite the `write!` and `writeln!` macros

These are reimplemented using the new `core::fmt` module.
上级 854d95f9
......@@ -251,10 +251,17 @@ fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
/// write!(&mut w, "formatted {}", "arguments");
/// ```
#[macro_export]
#[cfg(not(stage0))]
macro_rules! write(
($dst:expr, $($arg:tt)*) => ({
let dst: &mut ::std::io::Writer = $dst;
format_args!(|args| { ::std::fmt::write(dst, args) }, $($arg)*)
format_args_method!($dst, write_fmt, $($arg)*)
})
)
#[cfg(stage0)]
#[macro_export]
macro_rules! write(
($dst:expr, $($arg:tt)*) => ({
format_args!(|args| { $dst.write_fmt(args) }, $($arg)*)
})
)
......@@ -262,9 +269,9 @@ fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
/// the message is written.
#[macro_export]
macro_rules! writeln(
($dst:expr, $($arg:tt)*) => ({
let dst: &mut ::std::io::Writer = $dst;
format_args!(|args| { ::std::fmt::writeln(dst, args) }, $($arg)*)
($dst:expr, $fmt:expr $($arg:tt)*) => ({
format_args!(|args| { $dst.write_fmt(args) },
concat!($fmt, "\n") $($arg)*)
})
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册