@@ -16,7 +16,6 @@
//! them in the future to instead emit any format desired.

use std::fmt;
use std::io;
use std::strbuf::StrBuf;

use syntax::ast;
@@ -52,46 +51,46 @@ impl FnStyleSpace {
impl fmt::Show for clean::Generics {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) }
try!(f.buf.write("<".as_bytes()));
try!(f.write("<".as_bytes()));

for (i, life) in self.lifetimes.iter().enumerate() {
if i > 0 {
try!(f.buf.write(", ".as_bytes()));
try!(f.write(", ".as_bytes()));
}
try!(write!(f.buf, "{}", *life));
try!(write!(f, "{}", *life));
}

if self.type_params.len() > 0 {
if self.lifetimes.len() > 0 {
try!(f.buf.write(", ".as_bytes()));
try!(f.write(", ".as_bytes()));
}

for (i, tp) in self.type_params.iter().enumerate() {
if i > 0 {
try!(f.buf.write(", ".as_bytes()))
try!(f.write(", ".as_bytes()))
}
try!(f.buf.write(tp.name.as_bytes()));
try!(f.write(tp.name.as_bytes()));

if tp.bounds.len() > 0 {
try!(f.buf.write(": ".as_bytes()));
try!(f.write(": ".as_bytes()));
for (i, bound) in tp.bounds.iter().enumerate() {
if i > 0 {
try!(f.buf.write(" + ".as_bytes()));
try!(f.write(" + ".as_bytes()));
}
try!(write!(f.buf, "{}", *bound));
try!(write!(f, "{}", *bound));
}
}
}
}
try!(f.buf.write(">".as_bytes()));
try!(f.write(">".as_bytes()));
Ok(())
}
}

impl fmt::Show for clean::Lifetime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(f.buf.write("'".as_bytes()));
try!(f.buf.write(self.get_ref().as_bytes()));
try!(f.write("'".as_bytes()));
try!(f.write(self.get_ref().as_bytes()));
Ok(())
}
}
@@ -100,10 +99,10 @@ impl fmt::Show for clean::TyParamBound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::RegionBound => {
f.buf.write("'static".as_bytes())
f.write("::".as_bytes())
}
clean::TraitBound(ref ty) => {
write!(f.buf, "{}", *ty)
write!(f, "{}", *ty)
}
}
}
@@ -112,32 +111,33 @@ impl fmt::Show for clean::TyParamBound {
impl fmt::Show for clean::Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.global {
try!(f.buf.write("::".as_bytes()))
try!(f.write("::".as_bytes()))
}

for (i, seg) in self.segments.iter().enumerate() {
if i > 0 {
try!(f.buf.write("::".as_bytes()))
try!(f.write("::".as_bytes()))
}
try!(f.buf.write(seg.name.as_bytes()));
try!(f.write(seg.name.as_bytes()));

if seg.lifetimes.len() > 0 || seg.types.len() > 0 {
try!(f.buf.write("<".as_bytes()));
try!(f.write("<".as_bytes()));
let mut comma = false;
for lifetime in seg.lifetimes.iter() {
if comma {
try!(f.buf.write(", ".as_bytes()));
try!(f.write(", ".as_bytes()));
}
comma = true;
try!(write!(f.buf, "{}", *lifetime));
try!(write!(f, "{}", *lifetime));
}
for ty in seg.types.iter() {
if comma {
try!(f.buf.write(", ".as_bytes()));
try!(f.write(", ".as_bytes()));
}
comma = true;
try!(write!(f.buf, "{}", *ty));
try!(write!(f, "{}", *ty));
}
try!(f.buf.write(">".as_bytes()));
try!(f.write(">".as_bytes()));
}
}
Ok(())
@@ -146,7 +146,7 @@ impl fmt::Show for clean::Path {

/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
/// rendering function with the necessary arguments for linking to a local path.
fn resolved_path(w: &mut io::Writer, did: ast::DefId, p: &clean::Path,
fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
print_all: bool) -> fmt::Result {
path(w, p, print_all,
|cache, loc| {
@@ -170,7 +170,7 @@ fn resolved_path(w: &mut io::Writer, did: ast::DefId, p: &clean::Path,
})
}

fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
root: |&render::Cache, &[StrBuf]| -> Option<StrBuf>,
info: |&render::Cache| -> Option<(Vec<StrBuf> , ItemType)>)
-> fmt::Result
@@ -264,7 +264,7 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
}

/// Helper to render type parameters
fn tybounds(w: &mut io::Writer,
fn tybounds(w: &mut fmt::Formatter,
typarams: &Option<Vec<clean::TyParamBound> >) -> fmt::Result {
match *typarams {
Some(ref params) => {
@@ -286,13 +286,13 @@ impl fmt::Show for clean::Type {
match *self {
clean::TyParamBinder(id) | clean::Generic(id) => {
let m = cache_key.get().unwrap();
f.buf.write(m.typarams.get(&id).as_bytes())
f.write(m.typarams.get(&id).as_bytes())
}
clean::ResolvedPath{ did, ref typarams, ref path} => {
try!(resolved_path(f.buf, did, path, false));
try!(resolved_path(f, did, path, false));
tybounds(f.buf, typarams)
}
clean::Self(..) => f.buf.write("Self".as_bytes()),
clean::Self(..) => f.write("Self".as_bytes()),
clean::Primitive(prim) => {
let s = match prim {
ast::TyInt(ast::TyI) => "int",
@@ -312,11 +312,11 @@ impl fmt::Show for clean::Type {
ast::TyBool => "bool",
ast::TyChar => "char",
};
f.buf.write(s.as_bytes())
f.write(s.as_bytes())
}
clean::Closure(ref decl, ref region) => {
write!(f.buf, "{style}{lifetimes}|{args}|{bounds}\
{arrow, select, yes{ -&gt; {ret}} other{}}",
write!(f, "{style}{lifetimes}|{args}|{bounds}\
{arrow, select, yes{ -&gt; {ret}} other{}}",
style = FnStyleSpace(decl.fn_style),
lifetimes = if decl.lifetimes.len() == 0 {
"".to_owned()
@@ -351,8 +351,8 @@ impl fmt::Show for clean::Type {
})
}
clean::Proc(ref decl) => {
write!(f.buf, "{style}{lifetimes}proc({args}){bounds}\
{arrow, select, yes{ -&gt; {ret}} other{}}",
write!(f, "{style}{lifetimes}proc({args}){bounds}\
{arrow, select, yes{ -&gt; {ret}} other{}}",
style = FnStyleSpace(decl.fn_style),
lifetimes = if decl.lifetimes.len() == 0 {
"".to_strbuf()
@@ -374,7 +374,7 @@ impl fmt::Show for clean::Type {
ret = decl.decl.output)
}
clean::BareFunction(ref decl) => {
write!(f.buf, "{}{}fn{}{}",
write!(f, "{}{}fn{}{}",
FnStyleSpace(decl.fn_style),
match decl.abi.as_slice() {
"" => " extern ".to_strbuf(),
@@ -385,35 +385,35 @@ impl fmt::Show for clean::Type {
decl.decl)
}
clean::Tuple(ref typs) => {
try!(f.buf.write("(".as_bytes()));
try!(f.write("(".as_bytes()));
for (i, typ) in typs.iter().enumerate() {
if i > 0 {
try!(f.buf.write(", ".as_bytes()))
try!(f.write(", ".as_bytes()))
}
try!(write!(f.buf, "{}", *typ));
try!(write!(f, "{}", *typ));
}
f.buf.write(")".as_bytes())
f.write(")".as_bytes())
}
clean::Vector(ref t) => write!(f.buf, "[{}]", **t),
clean::Vector(ref t) => write!(f, "[{}]", **t),
clean::FixedVector(ref t, ref s) => {
write!(f.buf, "[{}, ..{}]", **t, *s)
}
clean::String => f.buf.write("str".as_bytes()),
clean::Bool => f.buf.write("bool".as_bytes()),
clean::Unit => f.buf.write("()".as_bytes()),
clean::Bottom => f.buf.write("!".as_bytes()),
clean::Unique(ref t) => write!(f.buf, "~{}", **t),
clean::Managed(ref t) => write!(f.buf, "@{}", **t),
write!(f, "[{}, ..{}]", **t, *s)
}
clean::String => f.write("str".as_bytes()),
clean::Bool => f.write("bool".as_bytes()),
clean::Unit => f.write("()".as_bytes()),
clean::Bottom => f.write("!".as_bytes()),
clean::Unique(ref t) => write!(f, "~{}", **t),
clean::Managed(ref t) => write!(f, "@{}", **t),
clean::RawPointer(m, ref t) => {
write!(f.buf, "*{}{}",
write!(f, "*{}{}",
match m {
clean::Mutable => "mut ",
clean::Immutable => "",
}, **t)
}
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
let lt = match *l { Some(ref l) => format!("{} ", *l), _ => "".to_owned() };
write!(f.buf, "&amp;{}{}{}",
write!(f, "&amp;{}{}{}",
lt,
match mutability {
clean::Mutable => "mut ",
@@ -428,19 +428,19 @@ impl fmt::Show for clean::Type {
impl fmt::Show for clean::Arguments {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (i, input) in self.values.iter().enumerate() {
if i > 0 { try!(write!(f.buf, ", ")); }
if i > 0 { try!(write!(f, ", ")); }
if input.name.len() > 0 {
try!(write!(f.buf, "{}: ", input.name));
try!(write!(f, "{}: ", input.name));
}
try!(write!(f.buf, "{}", input.type_));
try!(write!(f, "{}", input.type_));
}
Ok(())
}
}

impl fmt::Show for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
write!(f, "({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
args = self.inputs,
arrow = match self.output { clean::Unit => "no", _ => "yes" },
ret = self.output)
@@ -475,7 +475,7 @@ impl<'a> fmt::Show for Method<'a> {
}
args.push_str(format!("{}", input.type_));
}
write!(f.buf,
write!(f,
"({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
args = args,
arrow = match d.output { clean::Unit => "no", _ => "yes" },
@@ -486,7 +486,7 @@ impl<'a> fmt::Show for Method<'a> {
impl fmt::Show for VisSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.get() {
Some(ast::Public) => write!(f.buf, "pub "),
Some(ast::Public) => write!(f, "pub "),
Some(ast::Inherited) | None => Ok(())
}
}
@@ -495,7 +495,7 @@ impl fmt::Show for VisSpace {
impl fmt::Show for FnStyleSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.get() {
ast::UnsafeFn => write!(f.buf, "unsafe "),
ast::UnsafeFn => write!(f, "unsafe "),
ast::NormalFn => Ok(())
}
}
@@ -506,23 +506,23 @@ impl fmt::Show for clean::ViewPath {
match *self {
clean::SimpleImport(ref name, ref src) => {
if *name == src.path.segments.last().unwrap().name {
write!(f.buf, "use {};", *src)
write!(f, "use {};", *src)
} else {
write!(f.buf, "use {} = {};", *name, *src)
write!(f, "use {} = {};", *name, *src)
}
}
clean::GlobImport(ref src) => {
write!(f.buf, "use {}::*;", *src)
write!(f, "use {}::*;", *src)
}
clean::ImportList(ref src, ref names) => {
try!(write!(f.buf, "use {}::\\{", *src));
try!(write!(f, "use {}::\\{", *src));
for (i, n) in names.iter().enumerate() {
if i > 0 {
try!(write!(f.buf, ", "));
try!(write!(f, ", "));
}
try!(write!(f.buf, "{}", *n));
try!(write!(f, "{}", *n));
}
write!(f.buf, "\\};")
write!(f, "\\};")
}
}
}
@@ -531,13 +531,13 @@ impl fmt::Show for clean::ViewPath {
impl fmt::Show for clean::ImportSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.did {
Some(did) => resolved_path(f.buf, did, &self.path, true),
Some(did) => resolved_path(f, did, &self.path, true),
_ => {
for (i, seg) in self.path.segments.iter().enumerate() {
if i > 0 {
try!(write!(f.buf, "::"))
try!(write!(f, "::"))
}
try!(write!(f.buf, "{}", seg.name));
try!(write!(f, "{}", seg.name));
}
Ok(())
}
@@ -557,9 +557,9 @@ impl fmt::Show for clean::ViewListIdent {
types: Vec::new(),
})
};
resolved_path(f.buf, did, &path, false)
resolved_path(f, did, &path, false)
}
_ => write!(f.buf, "{}", self.name),
_ => write!(f, "{}", self.name),
}
}
}
@@ -26,7 +26,7 @@ pub struct Page<'a> {

pub fn render<T: fmt::Show, S: fmt::Show>(
dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T)
-> fmt::Result
-> io::IoResult<()>
{
write!(dst,
r##"<!DOCTYPE html>
@@ -29,7 +29,6 @@
use libc;
use std::cell::RefCell;
use std::fmt;
use std::io;
use std::slice;
use std::str;
use collections::HashMap;
@@ -141,7 +140,7 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> {

local_data_key!(used_header_map: RefCell<HashMap<StrBuf, uint>>)

pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
extern fn block(ob: *mut hoedown_buffer, text: *hoedown_buffer,
lang: *hoedown_buffer, opaque: *mut libc::c_void) {
unsafe {
@@ -355,13 +354,13 @@ impl<'a> fmt::Show for Markdown<'a> {
let Markdown(md) = *self;
// This is actually common enough to special-case
if md.len() == 0 { return Ok(()) }
render(fmt.buf, md.as_slice(), false)
render(fmt, md.as_slice(), false)
}
}

impl<'a> fmt::Show for MarkdownWithToc<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let MarkdownWithToc(md) = *self;
render(fmt.buf, md.as_slice(), true)
render(fmt, md.as_slice(), true)
}
}
@@ -587,7 +587,7 @@ impl<'a> SourceCollector<'a> {
root_path: root_path.as_slice(),
};
try!(layout::render(&mut w as &mut Writer, &self.cx.layout,
&page, &(""), &Source(contents)));
&page, &(""), &Source(contents)));
try!(w.flush());
return Ok(());
}
@@ -925,8 +925,8 @@ impl Context {
// write sycall all the time.
let mut writer = BufferedWriter::new(w);
try!(layout::render(&mut writer as &mut Writer, &cx.layout, &page,
&Sidebar{ cx: cx, item: it },
&Item{ cx: cx, item: it }));
&Sidebar{ cx: cx, item: it },
&Item{ cx: cx, item: it }));
writer.flush()
}

@@ -997,17 +997,17 @@ impl<'a> Item<'a> {
impl<'a> fmt::Show for Item<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
// Write the breadcrumb trail header for the top
try!(write!(fmt.buf, "\n<h1 class='fqn'>"));
try!(write!(fmt, "\n<h1 class='fqn'>"));
match self.item.inner {
clean::ModuleItem(ref m) => if m.is_crate {
try!(write!(fmt.buf, "Crate "));
try!(write!(fmt, "Crate "));
} else {
try!(write!(fmt.buf, "Module "));
try!(write!(fmt, "Module "));
},
clean::FunctionItem(..) => try!(write!(fmt.buf, "Function ")),
clean::TraitItem(..) => try!(write!(fmt.buf, "Trait ")),
clean::StructItem(..) => try!(write!(fmt.buf, "Struct ")),
clean::EnumItem(..) => try!(write!(fmt.buf, "Enum ")),
clean::FunctionItem(..) => try!(write!(fmt, "Function ")),
clean::TraitItem(..) => try!(write!(fmt, "Trait ")),
clean::StructItem(..) => try!(write!(fmt, "Struct ")),
clean::EnumItem(..) => try!(write!(fmt, "Enum ")),
_ => {}
}
let cur = self.cx.current.as_slice();
@@ -1017,16 +1017,16 @@ impl<'a> fmt::Show for Item<'a> {
for _ in range(0, cur.len() - i - 1) {
trail.push_str("../");
}
try!(write!(fmt.buf, "<a href='{}index.html'>{}</a>::",
trail, component.as_slice()));
try!(write!(fmt, "<a href='{}index.html'>{}</a>::",
trail, component.as_slice()));
}
try!(write!(fmt.buf, "<a class='{}' href=''>{}</a>",
shortty(self.item), self.item.name.get_ref().as_slice()));
try!(write!(fmt, "<a class='{}' href=''>{}</a>",
shortty(self.item), self.item.name.get_ref().as_slice()));

// Write stability attributes
match attr::find_stability(self.item.attrs.iter()) {
Some(ref stability) => {
try!(write!(fmt.buf,
try!(write!(fmt,
"<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
lvl = stability.level.to_str(),
reason = match stability.text {
@@ -1039,22 +1039,22 @@ impl<'a> fmt::Show for Item<'a> {

// Write `src` tag
if self.cx.include_sources {
try!(write!(fmt.buf, "<a class='source' href='{}'>[src]</a>",
try!(write!(fmt, "<a class='source' href='{}'>[src]</a>",
self.link()));
}
try!(write!(fmt.buf, "</h1>\n"));
try!(write!(fmt, "</h1>\n"));

match self.item.inner {
clean::ModuleItem(ref m) => {
item_module(fmt.buf, self.cx, self.item, m.items.as_slice())
item_module(fmt, self.cx, self.item, m.items.as_slice())
}
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
item_function(fmt.buf, self.item, f),
clean::TraitItem(ref t) => item_trait(fmt.buf, self.item, t),
clean::StructItem(ref s) => item_struct(fmt.buf, self.item, s),
clean::EnumItem(ref e) => item_enum(fmt.buf, self.item, e),
clean::TypedefItem(ref t) => item_typedef(fmt.buf, self.item, t),
clean::MacroItem(ref m) => item_macro(fmt.buf, self.item, m),
item_function(fmt, self.item, f),
clean::TraitItem(ref t) => item_trait(fmt, self.item, t),
clean::StructItem(ref s) => item_struct(fmt, self.item, s),
clean::EnumItem(ref e) => item_enum(fmt, self.item, e),
clean::TypedefItem(ref t) => item_typedef(fmt, self.item, t),
clean::MacroItem(ref m) => item_macro(fmt, self.item, m),
_ => Ok(())
}
}
@@ -1097,7 +1097,7 @@ fn shorter<'a>(s: Option<&'a str>) -> &'a str {
}
}

fn document(w: &mut Writer, item: &clean::Item) -> fmt::Result {
fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
match item.doc_value() {
Some(s) => {
try!(write!(w, "<div class='docblock'>{}</div>", Markdown(s)));
@@ -1107,7 +1107,7 @@ fn document(w: &mut Writer, item: &clean::Item) -> fmt::Result {
Ok(())
}

fn item_module(w: &mut Writer, cx: &Context,
fn item_module(w: &mut fmt::Formatter, cx: &Context,
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
try!(document(w, item));
debug!("{:?}", items);
@@ -1196,13 +1196,12 @@ fn item_module(w: &mut Writer, cx: &Context,
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Initializer(s, item) = *self;
if s.len() == 0 { return Ok(()); }
try!(write!(f.buf, "<code> = </code>"));
try!(write!(f, "<code> = </code>"));
if s.contains("\n") {
write!(f.buf,
"<a href='{}'>[definition]</a>",
write!(f, "<a href='{}'>[definition]</a>",
item.link())
} else {
write!(f.buf, "<code>{}</code>", s.as_slice())
write!(f, "<code>{}</code>", s.as_slice())
}
}
}
@@ -1262,7 +1261,7 @@ fn item_module(w: &mut Writer, cx: &Context,
write!(w, "</table>")
}

fn item_function(w: &mut Writer, it: &clean::Item,
fn item_function(w: &mut fmt::Formatter, it: &clean::Item,
f: &clean::Function) -> fmt::Result {
try!(write!(w, "<pre class='rust fn'>{vis}{fn_style}fn \
{name}{generics}{decl}</pre>",
@@ -1274,7 +1273,7 @@ fn item_function(w: &mut Writer, it: &clean::Item,
document(w, it)
}

fn item_trait(w: &mut Writer, it: &clean::Item,
fn item_trait(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Trait) -> fmt::Result {
let mut parents = StrBuf::new();
if t.parents.len() > 0 {
@@ -1318,7 +1317,7 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
// Trait documentation
try!(document(w, it));

fn meth(w: &mut Writer, m: &clean::TraitMethod) -> fmt::Result {
fn meth(w: &mut fmt::Formatter, m: &clean::TraitMethod) -> fmt::Result {
try!(write!(w, "<h3 id='{}.{}' class='method'><code>",
shortty(m.item()),
*m.item().name.get_ref()));
@@ -1374,8 +1373,8 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
Ok(())
}

fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
fn fun(w: &mut Writer, it: &clean::Item, fn_style: ast::FnStyle,
fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
fn fun(w: &mut fmt::Formatter, it: &clean::Item, fn_style: ast::FnStyle,
g: &clean::Generics, selfty: &clean::SelfTy,
d: &clean::FnDecl) -> fmt::Result {
write!(w, "{}fn <a href='\\#{ty}.{name}' class='fnname'>{name}</a>\
@@ -1400,7 +1399,7 @@ fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
}
}

fn item_struct(w: &mut Writer, it: &clean::Item,
fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
s: &clean::Struct) -> fmt::Result {
try!(write!(w, "<pre class='rust struct'>"));
try!(render_struct(w,
@@ -1437,7 +1436,8 @@ fn item_struct(w: &mut Writer, it: &clean::Item,
render_methods(w, it)
}

fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
e: &clean::Enum) -> fmt::Result {
try!(write!(w, "<pre class='rust enum'>{}enum {}{}",
VisSpace(it.visibility),
it.name.get_ref().as_slice(),
@@ -1533,7 +1533,7 @@ fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
Ok(())
}

fn render_struct(w: &mut Writer, it: &clean::Item,
fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
g: Option<&clean::Generics>,
ty: doctree::StructType,
fields: &[clean::Item],
@@ -1597,7 +1597,7 @@ fn render_struct(w: &mut Writer, it: &clean::Item,
Ok(())
}

fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
fn render_methods(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
match cache_key.get().unwrap().impls.find(&it.id) {
Some(v) => {
let mut non_trait = v.iter().filter(|p| {
@@ -1642,7 +1642,7 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
Ok(())
}

fn render_impl(w: &mut Writer, i: &clean::Impl,
fn render_impl(w: &mut fmt::Formatter, i: &clean::Impl,
dox: &Option<StrBuf>) -> fmt::Result {
try!(write!(w, "<h3 class='impl'><code>impl{} ", i.generics));
let trait_id = match i.trait_ {
@@ -1664,8 +1664,8 @@ fn render_impl(w: &mut Writer, i: &clean::Impl,
None => {}
}

fn docmeth(w: &mut Writer, item: &clean::Item,
dox: bool) -> io::IoResult<()> {
fn docmeth(w: &mut fmt::Formatter, item: &clean::Item,
dox: bool) -> fmt::Result {
try!(write!(w, "<h4 id='method.{}' class='method'><code>",
*item.name.get_ref()));
try!(render_method(w, item));
@@ -1714,7 +1714,7 @@ fn render_impl(w: &mut Writer, i: &clean::Impl,
Ok(())
}

fn item_typedef(w: &mut Writer, it: &clean::Item,
fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Typedef) -> fmt::Result {
try!(write!(w, "<pre class='rust typedef'>type {}{} = {};</pre>",
it.name.get_ref().as_slice(),
@@ -1728,21 +1728,21 @@ impl<'a> fmt::Show for Sidebar<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let cx = self.cx;
let it = self.item;
try!(write!(fmt.buf, "<p class='location'>"));
try!(write!(fmt, "<p class='location'>"));
let len = cx.current.len() - if it.is_mod() {1} else {0};
for (i, name) in cx.current.iter().take(len).enumerate() {
if i > 0 {
try!(write!(fmt.buf, "&\\#8203;::"));
try!(write!(fmt, "&\\#8203;::"));
}
try!(write!(fmt.buf, "<a href='{}index.html'>{}</a>",
try!(write!(fmt, "<a href='{}index.html'>{}</a>",
cx.root_path
.as_slice()
.slice_to((cx.current.len() - i - 1) * 3),
*name));
}
try!(write!(fmt.buf, "</p>"));
try!(write!(fmt, "</p>"));

fn block(w: &mut Writer, short: &str, longty: &str,
fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
cur: &clean::Item, cx: &Context) -> fmt::Result {
let items = match cx.sidebar.find_equiv(&short) {
Some(items) => items.as_slice(),
@@ -1770,12 +1770,12 @@ impl<'a> fmt::Show for Sidebar<'a> {
Ok(())
}

try!(block(fmt.buf, "mod", "Modules", it, cx));
try!(block(fmt.buf, "struct", "Structs", it, cx));
try!(block(fmt.buf, "enum", "Enums", it, cx));
try!(block(fmt.buf, "trait", "Traits", it, cx));
try!(block(fmt.buf, "fn", "Functions", it, cx));
try!(block(fmt.buf, "macro", "Macros", it, cx));
try!(block(fmt, "mod", "Modules", it, cx));
try!(block(fmt, "struct", "Structs", it, cx));
try!(block(fmt, "enum", "Enums", it, cx));
try!(block(fmt, "trait", "Traits", it, cx));
try!(block(fmt, "fn", "Functions", it, cx));
try!(block(fmt, "macro", "Macros", it, cx));
Ok(())
}
}
@@ -1808,19 +1808,18 @@ impl<'a> fmt::Show for Source<'a> {
cols += 1;
tmp /= 10;
}
try!(write!(fmt.buf, "<pre class='line-numbers'>"));
try!(write!(fmt, "<pre class='line-numbers'>"));
for i in range(1, lines + 1) {
try!(write!(fmt.buf, "<span id='{0:u}'>{0:1$u}</span>\n", i, cols));
try!(write!(fmt, "<span id='{0:u}'>{0:1$u}</span>\n", i, cols));
}
try!(write!(fmt.buf, "</pre>"));
try!(write!(fmt.buf, "{}", highlight::highlight(s.as_slice(), None)));
try!(write!(fmt, "</pre>"));
try!(write!(fmt, "{}", highlight::highlight(s.as_slice(), None)));
Ok(())
}
}

fn item_macro(w: &mut Writer, it: &clean::Item,
fn item_macro(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Macro) -> fmt::Result {
try!(w.write_str(highlight::highlight(t.source.as_slice(),
Some("macro")).as_slice()));
try!(w.write(highlight::highlight(t.source.as_slice(), Some("macro")).as_bytes()));
document(w, it)
}
@@ -174,17 +174,17 @@ impl TocBuilder {

impl fmt::Show for Toc {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt.buf, "<ul>"));
try!(write!(fmt, "<ul>"));
for entry in self.entries.iter() {
// recursively format this table of contents (the
// `{children}` is the key).
try!(write!(fmt.buf,
try!(write!(fmt,
"\n<li><a href=\"\\#{id}\">{num} {name}</a>{children}</li>",
id = entry.id,
num = entry.sec_number, name = entry.name,
children = entry.children))
}
write!(fmt.buf, "</ul>")
write!(fmt, "</ul>")
}
}

@@ -379,7 +379,7 @@ impl UvError {

impl fmt::Show for UvError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}: {}", self.name(), self.desc())
write!(f, "{}: {}", self.name(), self.desc())
}
}

@@ -28,9 +28,7 @@ macro_rules! uvdebug (
)

pub fn dumb_println(args: &fmt::Arguments) {
use std::io;
use std::rt;

let mut w = rt::Stderr;
let _ = fmt::writeln(&mut w as &mut io::Writer, args);
let _ = writeln!(&mut w, "{}", args);
}
@@ -96,18 +96,18 @@ pub struct Version {
impl fmt::Show for Version {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, "{}.{}.{}", self.major, self.minor, self.patch))
try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch))
if !self.pre.is_empty() {
try!(write!(f.buf, "-"));
try!(write!(f, "-"));
for (i, x) in self.pre.iter().enumerate() {
if i != 0 { try!(write!(f.buf, ".")) };
if i != 0 { try!(write!(f, ".")) };
try!(x.fmt(f));
}
}
if !self.build.is_empty() {
try!(write!(f.buf, "+"));
try!(write!(f, "+"));
for (i, x) in self.build.iter().enumerate() {
if i != 0 { try!(write!(f.buf, ".")) };
if i != 0 { try!(write!(f, ".")) };
try!(x.fmt(f));
}
}
@@ -170,8 +170,8 @@ impl fmt::Show for FromBase64Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
InvalidBase64Character(ch, idx) =>
write!(f.buf, "Invalid character '{}' at position {}", ch, idx),
InvalidBase64Length => write!(f.buf, "Invalid length"),
write!(f, "Invalid character '{}' at position {}", ch, idx),
InvalidBase64Length => write!(f, "Invalid length"),
}
}
}
@@ -69,8 +69,8 @@ impl fmt::Show for FromHexError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
InvalidHexCharacter(ch, idx) =>
write!(f.buf, "Invalid character '{}' at position {}", ch, idx),
InvalidHexLength => write!(f.buf, "Invalid input length"),
write!(f, "Invalid character '{}' at position {}", ch, idx),
InvalidHexLength => write!(f, "Invalid input length"),
}
}
}
@@ -2267,7 +2267,7 @@ impl<A:ToJson> ToJson for Option<A> {
impl fmt::Show for Json {
/// Encodes a json value into a string
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.to_writer(f.buf)
self.to_writer(f).map_err(|_| fmt::WriteError)
}
}

@@ -59,7 +59,7 @@
//!
//! impl fmt::Show for Flags {
//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
//! write!(f.buf, "hi!")
//! write!(f, "hi!")
//! }
//! }
//!
@@ -549,7 +549,7 @@ pub trait Poly {
/// ```
pub fn format(args: &Arguments) -> ~str {
let mut output = io::MemWriter::new();
output.write_fmt(args).unwrap();
let _ = write!(&mut output, "{}", args);
str::from_utf8(output.unwrap().as_slice()).unwrap().to_owned()
}

@@ -16,7 +16,7 @@ use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
use iter::ExactSize;
use ops::Drop;
use option::{Some, None, Option};
use result::{Ok, Err, ResultUnwrap};
use result::{Ok, Err};
use slice::{ImmutableVector, MutableVector};
use slice;
use vec::Vec;
@@ -381,9 +381,9 @@ impl IoError {

impl fmt::Show for IoError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(fmt.buf.write_str(self.desc));
try!(write!(fmt, "{}", self.desc));
match self.detail {
Some(ref s) => write!(fmt.buf, " ({})", *s),
Some(ref s) => write!(fmt, " ({})", *s),
None => Ok(())
}
}
@@ -35,22 +35,22 @@ impl fmt::Show for IpAddr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
Ipv4Addr(a, b, c, d) =>
write!(fmt.buf, "{}.{}.{}.{}", a, b, c, d),
write!(fmt, "{}.{}.{}.{}", a, b, c, d),

// Ipv4 Compatible address
Ipv6Addr(0, 0, 0, 0, 0, 0, g, h) => {
write!(fmt.buf, "::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
write!(fmt, "::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
(h >> 8) as u8, h as u8)
}

// Ipv4-Mapped address
Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, g, h) => {
write!(fmt.buf, "::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
write!(fmt, "::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
(h >> 8) as u8, h as u8)
}

Ipv6Addr(a, b, c, d, e, f, g, h) =>
write!(fmt.buf, "{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}",
write!(fmt, "{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}",
a, b, c, d, e, f, g, h)
}
}
@@ -65,8 +65,8 @@ pub struct SocketAddr {
impl fmt::Show for SocketAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.ip {
Ipv4Addr(..) => write!(f.buf, "{}:{}", self.ip, self.port),
Ipv6Addr(..) => write!(f.buf, "[{}]:{}", self.ip, self.port),
Ipv4Addr(..) => write!(f, "{}:{}", self.ip, self.port),
Ipv6Addr(..) => write!(f, "[{}]:{}", self.ip, self.port),
}
}
}
@@ -384,8 +384,6 @@ mod test {
})

pub fn socket_name(addr: SocketAddr) {
use result::ResultUnwrap;

let server = UdpSocket::bind(addr);

assert!(server.is_ok());
@@ -361,8 +361,8 @@ impl fmt::Show for ProcessExit {
/// Format a ProcessExit enum, to nicely present the information.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ExitStatus(code) => write!(f.buf, "exit code: {}", code),
ExitSignal(code) => write!(f.buf, "signal: {}", code),
ExitStatus(code) => write!(f, "exit code: {}", code),
ExitSignal(code) => write!(f, "signal: {}", code),
}
}
}
@@ -36,7 +36,7 @@ use mem::replace;
use option::{Option, Some, None};
use owned::Box;
use prelude::drop;
use result::{Ok, Err, ResultUnwrap};
use result::{Ok, Err};
use rt;
use rt::local::Local;
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
@@ -276,13 +276,13 @@ pub fn println(s: &str) {
/// Similar to `print`, but takes a `fmt::Arguments` structure to be compatible
/// with the `format_args!` macro.
pub fn print_args(fmt: &fmt::Arguments) {
with_task_stdout(|io| fmt::write(io, fmt))
with_task_stdout(|io| write!(io, "{}", fmt))
}

/// Similar to `println`, but takes a `fmt::Arguments` structure to be
/// compatible with the `format_args!` macro.
pub fn println_args(fmt: &fmt::Arguments) {
with_task_stdout(|io| fmt::writeln(io, fmt))
with_task_stdout(|io| writeln!(io, "{}", fmt))
}

/// Representation of a reader of a standard input stream
@@ -269,10 +269,9 @@ macro_rules! write(
/// the message is written.
#[macro_export]
macro_rules! writeln(
($dst:expr, $fmt:expr $($arg:tt)*) => ({
format_args!(|args| { $dst.write_fmt(args) },
concat!($fmt, "\n") $($arg)*)
})
($dst:expr, $fmt:expr $($arg:tt)*) => (
write!($dst, concat!($fmt, "\n") $($arg)*)
)
)

/// Equivalent to the `println!` macro except that a newline is not printed at
@@ -820,7 +820,6 @@ mod bench {
use super::test::Bencher;
use rand::{XorShiftRng, Rng};
use num::ToStrRadix;
use realstd::result::ResultUnwrap;

#[bench]
fn to_str_bin(b: &mut Bencher) {
@@ -857,7 +856,6 @@ mod bench {
use super::test::Bencher;
use rand::{XorShiftRng, Rng};
use num::ToStrRadix;
use realstd::result::ResultUnwrap;

#[bench]
fn to_str_bin(b: &mut Bencher) {
@@ -894,7 +892,6 @@ mod bench {
use super::test::Bencher;
use rand::{XorShiftRng, Rng};
use f64;
use realstd::result::ResultUnwrap;

#[bench]
fn float_to_str(b: &mut Bencher) {
@@ -1073,19 +1073,19 @@ impl fmt::Show for MapError {
ErrAlreadyExists => "File mapping for specified file already exists",
ErrZeroLength => "Zero-length mapping not allowed",
ErrUnknown(code) => {
return write!(out.buf, "Unknown error = {}", code)
return write!(out, "Unknown error = {}", code)
},
ErrVirtualAlloc(code) => {
return write!(out.buf, "VirtualAlloc failure = {}", code)
return write!(out, "VirtualAlloc failure = {}", code)
},
ErrCreateFileMappingW(code) => {
return write!(out.buf, "CreateFileMappingW failure = {}", code)
return write!(out, "CreateFileMappingW failure = {}", code)
},
ErrMapViewOfFile(code) => {
return write!(out.buf, "MapViewOfFile failure = {}", code)
return write!(out, "MapViewOfFile failure = {}", code)
}
};
write!(out.buf, "{}", str)
write!(out, "{}", str)
}
}

@@ -25,7 +25,7 @@ use option::{Some, None, Option};
use ptr::RawPtr;
use reflect;
use reflect::{MovePtr, align};
use result::{Ok, Err, ResultUnwrap};
use result::{Ok, Err};
use str::StrSlice;
use to_str::ToStr;
use slice::Vector;
@@ -390,9 +390,9 @@ fn begin_unwind_inner(msg: Box<Any:Send>,
Some(mut stderr) => {
Local::put(task);
// FIXME: what to do when the task printing fails?
let _err = format_args!(|args| ::fmt::writeln(stderr, args),
"task '{}' failed at '{}', {}:{}",
n, msg_s, file, line);
let _err = write!(stderr,
"task '{}' failed at '{}', {}:{}\n",
n, msg_s, file, line);
if backtrace::log_enabled() {
let _err = backtrace::write(stderr);
}
@@ -110,8 +110,9 @@ impl io::Writer for Stdio {
}

pub fn dumb_println(args: &fmt::Arguments) {
use io::Writer;
let mut w = Stderr;
let _ = fmt::writeln(&mut w as &mut io::Writer, args);
let _ = writeln!(&mut w, "{}", args);
}

pub fn abort(msg: &str) -> ! {
@@ -155,7 +155,7 @@ impl Architecture {

impl fmt::Show for Abi {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "\"{}\"", self.name())
write!(f, "\"{}\"", self.name())
}
}

@@ -711,7 +711,7 @@ pub enum IntTy {

impl fmt::Show for IntTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}",
write!(f, "{}",
ast_util::int_ty_to_str(*self, None, ast_util::AutoSuffix))
}
}
@@ -727,7 +727,7 @@ pub enum UintTy {

impl fmt::Show for UintTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}",
write!(f, "{}",
ast_util::uint_ty_to_str(*self, None, ast_util::AutoSuffix))
}
}
@@ -741,7 +741,7 @@ pub enum FloatTy {

impl fmt::Show for FloatTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", ast_util::float_ty_to_str(*self))
write!(f, "{}", ast_util::float_ty_to_str(*self))
}
}

@@ -41,7 +41,7 @@ impl PathElem {
impl fmt::Show for PathElem {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let slot = token::get_name(self.name());
write!(f.buf, "{}", slot)
write!(f, "{}", slot)
}
}

@@ -33,16 +33,16 @@ pub struct CrateId {

impl fmt::Show for CrateId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, "{}", self.path));
try!(write!(f, "{}", self.path));
let version = match self.version {
None => "0.0",
Some(ref version) => version.as_slice(),
};
if self.path == self.name ||
self.path.as_slice().ends_with(format!("/{}", self.name)) {
write!(f.buf, "\\#{}", version)
write!(f, "\\#{}", version)
} else {
write!(f.buf, "\\#{}:{}", self.name, version)
write!(f, "\\#{}:{}", self.name, version)
}
}
}
@@ -594,7 +594,7 @@ impl BytesContainer for InternedString {

impl fmt::Show for InternedString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.string.as_slice())
write!(f, "{}", self.string.as_slice())
}
}

@@ -427,8 +427,8 @@ fn split_char_first(s: &str, c: char) -> (StrBuf, StrBuf) {
impl fmt::Show for UserInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.pass {
Some(ref pass) => write!(f.buf, "{}:{}@", self.user, *pass),
None => write!(f.buf, "{}@", self.user),
Some(ref pass) => write!(f, "{}:{}@", self.user, *pass),
None => write!(f, "{}@", self.user),
}
}
}
@@ -824,30 +824,30 @@ impl fmt::Show for Url {
* result in just "http://somehost.com".
*/
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, "{}:", self.scheme));
try!(write!(f, "{}:", self.scheme));

if !self.host.is_empty() {
try!(write!(f.buf, "//"));
try!(write!(f, "//"));
match self.user {
Some(ref user) => try!(write!(f.buf, "{}", *user)),
Some(ref user) => try!(write!(f, "{}", *user)),
None => {}
}
match self.port {
Some(ref port) => try!(write!(f.buf, "{}:{}", self.host,
Some(ref port) => try!(write!(f, "{}:{}", self.host,
*port)),
None => try!(write!(f.buf, "{}", self.host)),
None => try!(write!(f, "{}", self.host)),
}
}

try!(write!(f.buf, "{}", self.path));
try!(write!(f, "{}", self.path));

if !self.query.is_empty() {
try!(write!(f.buf, "?{}", query_to_str(&self.query)));
try!(write!(f, "?{}", query_to_str(&self.query)));
}

match self.fragment {
Some(ref fragment) => {
write!(f.buf, "\\#{}", encode_component(fragment.as_slice()))
write!(f, "\\#{}", encode_component(fragment.as_slice()))
}
None => Ok(()),
}
@@ -856,14 +856,14 @@ impl fmt::Show for Url {

impl fmt::Show for Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, "{}", self.path));
try!(write!(f, "{}", self.path));
if !self.query.is_empty() {
try!(write!(f.buf, "?{}", self.query))
try!(write!(f, "?{}", self.query))
}

match self.fragment {
Some(ref fragment) => {
write!(f.buf, "\\#{}", encode_component(fragment.as_slice()))
write!(f, "\\#{}", encode_component(fragment.as_slice()))
}
None => Ok(())
}
@@ -154,17 +154,17 @@ impl fmt::Show for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ErrorInvalidLength(found) =>
write!(f.buf, "Invalid length; expecting 32, 36 or 45 chars, \
found {}", found),
write!(f, "Invalid length; expecting 32, 36 or 45 chars, \
found {}", found),
ErrorInvalidCharacter(found, pos) =>
write!(f.buf, "Invalid character; found `{}` (0x{:02x}) at \
offset {}", found, found as uint, pos),
write!(f, "Invalid character; found `{}` (0x{:02x}) at \
offset {}", found, found as uint, pos),
ErrorInvalidGroups(found) =>
write!(f.buf, "Malformed; wrong number of groups: expected 1 \
or 5, found {}", found),
write!(f, "Malformed; wrong number of groups: expected 1 \
or 5, found {}", found),
ErrorInvalidGroupLength(group, found, expecting) =>
write!(f.buf, "Malformed; length of group {} was {}, \
expecting {}", group, found, expecting),
write!(f, "Malformed; length of group {} was {}, \
expecting {}", group, found, expecting),
}
}
}
@@ -474,7 +474,7 @@ impl FromStr for Uuid {
/// Convert the UUID to a hexadecimal-based string representation
impl fmt::Show for Uuid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.to_simple_str())
write!(f, "{}", self.to_simple_str())
}
}

@@ -19,7 +19,7 @@ pub mod kitty {

impl fmt::Show for cat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.name)
write!(f, "{}", self.name)
}
}

@@ -10,5 +10,5 @@

fn main() {
format!("{:d}", "3");
//~^ ERROR: failed to find an implementation of trait std::fmt::Signed
//~^ ERROR: failed to find an implementation of trait core::fmt::Signed
}
@@ -18,7 +18,7 @@ struct Number {

impl fmt::Show for Number {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.n)
write!(f, "{}", self.n)
}
}

@@ -26,7 +26,7 @@ struct MyWriter(ChanWriter);
impl Logger for MyWriter {
fn log(&mut self, record: &LogRecord) {
let MyWriter(ref mut inner) = *self;
fmt::writeln(inner as &mut Writer, record.args);
write!(inner, "{}", record.args);
}
}

@@ -45,5 +45,7 @@ fn main() {
debug!("debug");
info!("info");
});
assert_eq!(r.read_to_str().unwrap(), "info\n".to_owned());
let s = r.read_to_str().unwrap();
assert!(s.contains("info"));
assert!(!s.contains("debug"));
}
@@ -53,7 +53,7 @@ fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat {

impl fmt::Show for cat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.name)
write!(f, "{}", self.name)
}
}

@@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unused_must_use, dead_code)]
#![feature(macro_rules)]

use std::io::MemWriter;

@@ -36,7 +36,7 @@ struct J(Custom);
struct Custom;
impl fmt::Show for Custom {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "yay")
write!(f, "yay")
}
}

@@ -25,12 +25,12 @@ struct B;

impl fmt::Signed for A {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.buf.write("aloha".as_bytes())
f.write("aloha".as_bytes())
}
}
impl fmt::Signed for B {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.buf.write("adios".as_bytes())
f.write("adios".as_bytes())
}
}

@@ -195,9 +195,9 @@ fn test_format_args() {
let mut buf = MemWriter::new();
{
let w = &mut buf as &mut io::Writer;
format_args!(|args| { fmt::write(w, args); }, "{}", 1);
format_args!(|args| { fmt::write(w, args); }, "test");
format_args!(|args| { fmt::write(w, args); }, "{test}", test=3);
format_args!(|args| { write!(w, "{}", args); }, "{}", 1);
format_args!(|args| { write!(w, "{}", args); }, "test");
format_args!(|args| { write!(w, "{}", args); }, "{test}", test=3);
}
let s = str::from_utf8(buf.unwrap().as_slice()).unwrap().to_owned();
t!(s, "1test3");
@@ -29,7 +29,7 @@ enum square {

impl fmt::Show for square {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", match *self {
write!(f, "{}", match *self {
bot => { "R".to_owned() }
wall => { "#".to_owned() }
rock => { "*".to_owned() }
@@ -106,7 +106,7 @@ impl fmt::Show for AsciiArt {
.collect::<Vec<StrBuf>>();

// Concatenate the lines together using a new-line.
write!(f.buf, "{}", lines.connect("\n"))
write!(f, "{}", lines.connect("\n"))
}
}

@@ -17,7 +17,7 @@ struct Thingy {

impl fmt::Show for Thingy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "\\{ x: {}, y: {} \\}", self.x, self.y)
write!(f, "\\{ x: {}, y: {} \\}", self.x, self.y)
}
}

@@ -27,7 +27,7 @@ struct PolymorphicThingy<T> {

impl<T:fmt::Show> fmt::Show for PolymorphicThingy<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}", self.x)
write!(f, "{}", self.x)
}
}