Skip to content

Remove the io::Decorator trait #11394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ mod tests {
use serialize::Encodable;
use serialize;

use std::io::Decorator;
use std::io::mem::MemWriter;
use std::option::{None, Option, Some};

Expand All @@ -948,7 +947,7 @@ mod tests {
let mut ebml_w = writer::Encoder(&mut wr);
v.encode(&mut ebml_w);
}
let ebml_doc = reader::Doc(*wr.inner_ref());
let ebml_doc = reader::Doc(wr.get_ref());
let mut deser = reader::Decoder(ebml_doc);
let v1 = serialize::Decodable::decode(&mut deser);
debug!("v1 == {:?}", v1);
Expand Down
8 changes: 3 additions & 5 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::cast::transmute;
use std::f64;
use std::hashmap::HashMap;
use std::io;
use std::io::Decorator;
use std::io::mem::MemWriter;
use std::num;
use std::str;
Expand Down Expand Up @@ -464,7 +463,7 @@ impl Json{
pub fn to_pretty_str(&self) -> ~str {
let mut s = MemWriter::new();
self.to_pretty_writer(&mut s as &mut io::Writer);
str::from_utf8_owned(s.inner())
str::from_utf8_owned(s.unwrap())
}
}

Expand Down Expand Up @@ -1321,7 +1320,7 @@ impl to_str::ToStr for Json {
fn to_str(&self) -> ~str {
let mut s = MemWriter::new();
self.to_writer(&mut s as &mut io::Writer);
str::from_utf8_owned(s.inner())
str::from_utf8_owned(s.unwrap())
}
}

Expand Down Expand Up @@ -1508,12 +1507,11 @@ mod tests {

fn with_str_writer(f: |&mut io::Writer|) -> ~str {
use std::io::mem::MemWriter;
use std::io::Decorator;
use std::str;

let mut m = MemWriter::new();
f(&mut m as &mut io::Writer);
str::from_utf8_owned(m.inner())
str::from_utf8_owned(m.unwrap())
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,9 @@ mod tests {
fn test_boxplot_nonpositive() {
fn t(s: &Summary, expected: ~str) {
use std::io::mem::MemWriter;
use std::io::Decorator;
let mut m = MemWriter::new();
write_boxplot(&mut m as &mut io::Writer, s, 30);
let out = str::from_utf8_owned(m.inner());
let out = str::from_utf8_owned(m.unwrap());
assert_eq!(out, expected);
}

Expand Down
16 changes: 3 additions & 13 deletions src/libextra/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#[allow(missing_doc)];


use std::io::{Decorator, Writer};

use std::os;
use terminfo::*;
use terminfo::searcher::open;
Expand Down Expand Up @@ -234,20 +232,12 @@ impl<T: Writer> Terminal<T> {
color-8
} else { color }
}
}

impl<T: Writer> Decorator<T> for Terminal<T> {
fn inner(self) -> T {
self.out
}
pub fn unwrap(self) -> T { self.out }

fn inner_ref<'a>(&'a self) -> &'a T {
&self.out
}
pub fn get_ref<'a>(&'a self) -> &'a T { &self.out }

fn inner_mut_ref<'a>(&'a mut self) -> &'a mut T {
&mut self.out
}
pub fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out }
}

impl<T: Writer> Writer for Terminal<T> {
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ pub fn run_tests_console(opts: &TestOpts,

#[test]
fn should_sort_failures_before_printing_them() {
use std::io::Decorator;
use std::io::mem::MemWriter;
use std::str;

Expand Down Expand Up @@ -705,7 +704,7 @@ fn should_sort_failures_before_printing_them() {

st.write_failures();
let s = match st.out {
Raw(ref m) => str::from_utf8(*m.inner_ref()),
Raw(ref m) => str::from_utf8(m.get_ref()),
Pretty(_) => unreachable!()
};

Expand Down
3 changes: 1 addition & 2 deletions src/libextra/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ mod test {
use std::str;
use std::rand;
use std::num::Zero;
use std::io::Decorator;
use std::io::mem::MemWriter;

#[test]
Expand Down Expand Up @@ -798,7 +797,7 @@ mod test {
let u = Uuid::new_v4();
let mut wr = MemWriter::new();
u.encode(&mut ebml::writer::Encoder(&mut wr));
let doc = ebml::reader::Doc(wr.inner_ref().as_slice());
let doc = ebml::reader::Doc(wr.get_ref());
let u2 = Decodable::decode(&mut ebml::reader::Decoder(doc));
assert_eq!(u, u2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use arc::{Arc,RWArc};
use treemap::TreeMap;
use std::str;
use std::io;
use std::io::{File, Decorator};
use std::io::File;
use std::io::mem::MemWriter;

/**
Expand Down Expand Up @@ -261,7 +261,7 @@ fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str {
let mut writer = MemWriter::new();
let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
t.encode(&mut encoder);
str::from_utf8_owned(writer.inner())
str::from_utf8_owned(writer.unwrap())
}

// FIXME(#5121)
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::cast;
use std::cell::{Cell, RefCell};
use std::hashmap::{HashMap, HashSet};
use std::io::mem::MemWriter;
use std::io::{Writer, Seek, Decorator};
use std::str;
use std::vec;

Expand Down Expand Up @@ -1807,7 +1806,7 @@ pub static metadata_encoding_version : &'static [u8] =
pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
let mut wr = MemWriter::new();
encode_metadata_inner(&mut wr, parms, crate);
wr.inner()
wr.unwrap()
}

fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate) {
Expand Down Expand Up @@ -1900,7 +1899,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate)
ecx.stats.total_bytes.set(ebml_w.writer.tell());

if (tcx.sess.meta_stats()) {
for e in ebml_w.writer.inner_ref().iter() {
for e in ebml_w.writer.get_ref().iter() {
if *e == 0 {
ecx.stats.zero_bytes.set(ecx.stats.zero_bytes.get() + 1);
}
Expand Down Expand Up @@ -1930,5 +1929,5 @@ pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str {
abbrevs: tyencode::ac_no_abbrevs};
let mut wr = MemWriter::new();
tyencode::enc_ty(&mut wr, cx, t);
str::from_utf8_owned(wr.inner_ref().to_owned())
str::from_utf8_owned(wr.get_ref().to_owned())
}
3 changes: 1 addition & 2 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use std::cell::RefCell;
use std::hashmap::HashMap;
use std::io;
use std::io::{Decorator, Writer, Seek};
use std::io::mem::MemWriter;
use std::str;
use std::fmt;
Expand Down Expand Up @@ -73,7 +72,7 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
None => {
let wr = &mut MemWriter::new();
enc_sty(wr, cx, &ty::get(t).sty);
let s = str::from_utf8(*wr.inner_ref()).to_managed();
let s = str::from_utf8(wr.get_ref()).to_managed();
let mut short_names_cache = cx.tcx
.short_names_cache
.borrow_mut();
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,6 @@ fn mk_ctxt() -> @fake_ext_ctxt {

#[cfg(test)]
fn roundtrip(in_item: Option<@ast::item>) {
use std::io::Decorator;
use std::io::mem::MemWriter;

let in_item = in_item.unwrap();
Expand All @@ -1474,7 +1473,7 @@ fn roundtrip(in_item: Option<@ast::item>) {
let mut ebml_w = writer::Encoder(&mut wr);
encode_item_ast(&mut ebml_w, in_item);
}
let ebml_doc = reader::Doc(wr.inner_ref().as_slice());
let ebml_doc = reader::Doc(wr.get_ref());
let out_item = decode_item_ast(ebml_doc);

assert_eq!(in_item, out_item);
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use std::local_data;
use std::io;
use std::io::File;
use std::io::mem::MemWriter;
use std::io::Decorator;
use std::str;
use extra::getopts;
use extra::getopts::groups;
Expand Down Expand Up @@ -322,7 +321,7 @@ fn json_output(crate: clean::Crate, res: ~[plugins::PluginJson], dst: Path) {
let mut encoder = json::Encoder::new(&mut w as &mut io::Writer);
crate.encode(&mut encoder);
}
str::from_utf8_owned(w.inner())
str::from_utf8_owned(w.unwrap())
};
let crate_json = match json::from_str(crate_json_str) {
Ok(j) => j,
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ use prelude::*;

use cast;
use char::Char;
use io::Decorator;
use io::mem::MemWriter;
use io;
use str;
Expand Down Expand Up @@ -692,7 +691,7 @@ pub fn format(args: &Arguments) -> ~str {
pub unsafe fn format_unsafe(fmt: &[rt::Piece], args: &[Argument]) -> ~str {
let mut output = MemWriter::new();
write_unsafe(&mut output as &mut io::Writer, fmt, args);
return str::from_utf8_owned(output.inner());
return str::from_utf8_owned(output.unwrap());
}

impl<'a> Formatter<'a> {
Expand Down
Loading