diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-11 20:18:19 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-11 23:10:22 +1000 |
| commit | 5b109a175459e6428dafdd6aa5bedc6f598a3dff (patch) | |
| tree | 394de554cba4592a1ceb3bd8ed1b5f4091101625 /src/libstd/fmt/mod.rs | |
| parent | 0156af156d70efd5a3c96d0c5b8fc9bec39a7ae5 (diff) | |
| download | rust-5b109a175459e6428dafdd6aa5bedc6f598a3dff.tar.gz rust-5b109a175459e6428dafdd6aa5bedc6f598a3dff.zip | |
Add more type signatures to the docs; tweak a few of them.
Someone reading the docs won't know what the types of various things are, so this adds them in a few meaningful places to help with comprehension. cc #13423.
Diffstat (limited to 'src/libstd/fmt/mod.rs')
| -rw-r--r-- | src/libstd/fmt/mod.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 6514743c42e..3289475b184 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -276,16 +276,22 @@ references information on the stack. Under the hood, all of the related macros are implemented in terms of this. First off, some example usage is: -```ignore +``` use std::fmt; +use std::io; -# fn lol<T>() -> T { fail!() } -# let my_writer: &mut ::std::io::Writer = lol(); -# let my_fn: fn(&fmt::Arguments) = lol(); - +# #[allow(unused_must_use)] +# fn main() { format_args!(fmt::format, "this returns {}", "~str"); -format_args!(|args| { fmt::write(my_writer, args) }, "some {}", "args"); -format_args!(my_fn, "format {}", "string"); + +let some_writer: &mut io::Writer = &mut io::stdout(); +format_args!(|args| { fmt::write(some_writer, args) }, "print with a {}", "closure"); + +fn my_fmt_fn(args: &fmt::Arguments) { + fmt::write(&mut io::stdout(), args); +} +format_args!(my_fmt_fn, "or a {} too", "function"); +# } ``` The first argument of the `format_args!` macro is a function (or closure) which |
