From 2c658fabedcb4d8ca0d8c6e95184bc4ec0ae45aa Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 28 Mar 2013 19:31:19 -0700 Subject: [PATCH] std: remove prettyprint Everyone uses fmt!("%?", ...) instead of the prettyprint module, so I'm removing this file. --- src/libstd/prettyprint.rs | 199 ------------------------------- src/libstd/std.rc | 1 - src/test/run-pass/auto-encode.rs | 21 ---- 3 files changed, 221 deletions(-) delete mode 100644 src/libstd/prettyprint.rs diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs deleted file mode 100644 index ed4f3e957c02..000000000000 --- a/src/libstd/prettyprint.rs +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use serialize; - -use core::io::WriterUtil; -use core::io; - -pub struct Serializer { - wr: @io::Writer, -} - -pub fn Serializer(wr: @io::Writer) -> Serializer { - Serializer { wr: wr } -} - -impl serialize::Encoder for Serializer { - fn emit_nil(&self) { - self.wr.write_str(~"()") - } - - fn emit_uint(&self, v: uint) { - self.wr.write_str(fmt!("%?u", v)); - } - - fn emit_u64(&self, v: u64) { - self.wr.write_str(fmt!("%?_u64", v)); - } - - fn emit_u32(&self, v: u32) { - self.wr.write_str(fmt!("%?_u32", v)); - } - - fn emit_u16(&self, v: u16) { - self.wr.write_str(fmt!("%?_u16", v)); - } - - fn emit_u8(&self, v: u8) { - self.wr.write_str(fmt!("%?_u8", v)); - } - - fn emit_int(&self, v: int) { - self.wr.write_str(fmt!("%?", v)); - } - - fn emit_i64(&self, v: i64) { - self.wr.write_str(fmt!("%?_i64", v)); - } - - fn emit_i32(&self, v: i32) { - self.wr.write_str(fmt!("%?_i32", v)); - } - - fn emit_i16(&self, v: i16) { - self.wr.write_str(fmt!("%?_i16", v)); - } - - fn emit_i8(&self, v: i8) { - self.wr.write_str(fmt!("%?_i8", v)); - } - - fn emit_bool(&self, v: bool) { - self.wr.write_str(fmt!("%b", v)); - } - - fn emit_float(&self, v: float) { - self.wr.write_str(fmt!("%?_f", v)); - } - - fn emit_f64(&self, v: f64) { - self.wr.write_str(fmt!("%?_f64", v)); - } - - fn emit_f32(&self, v: f32) { - self.wr.write_str(fmt!("%?_f32", v)); - } - - fn emit_char(&self, v: char) { - self.wr.write_str(fmt!("%?", v)); - } - - fn emit_borrowed_str(&self, v: &str) { - self.wr.write_str(fmt!("&%?", v)); - } - - fn emit_owned_str(&self, v: &str) { - self.wr.write_str(fmt!("~%?", v)); - } - - fn emit_managed_str(&self, v: &str) { - self.wr.write_str(fmt!("@%?", v)); - } - - fn emit_borrowed(&self, f: &fn()) { - self.wr.write_str(~"&"); - f(); - } - - fn emit_owned(&self, f: &fn()) { - self.wr.write_str(~"~"); - f(); - } - - fn emit_managed(&self, f: &fn()) { - self.wr.write_str(~"@"); - f(); - } - - fn emit_enum(&self, _name: &str, f: &fn()) { - f(); - } - - fn emit_enum_variant(&self, v_name: &str, _v_id: uint, sz: uint, - f: &fn()) { - self.wr.write_str(v_name); - if sz > 0u { self.wr.write_str(~"("); } - f(); - if sz > 0u { self.wr.write_str(~")"); } - } - - fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { - if idx > 0u { self.wr.write_str(~", "); } - f(); - } - - fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { - self.wr.write_str(~"&["); - f(); - self.wr.write_str(~"]"); - } - - fn emit_owned_vec(&self, _len: uint, f: &fn()) { - self.wr.write_str(~"~["); - f(); - self.wr.write_str(~"]"); - } - - fn emit_managed_vec(&self, _len: uint, f: &fn()) { - self.wr.write_str(~"@["); - f(); - self.wr.write_str(~"]"); - } - - fn emit_vec_elt(&self, idx: uint, f: &fn()) { - if idx > 0u { self.wr.write_str(~", "); } - f(); - } - - fn emit_rec(&self, f: &fn()) { - self.wr.write_str(~"{"); - f(); - self.wr.write_str(~"}"); - } - - fn emit_struct(&self, name: &str, _len: uint, f: &fn()) { - self.wr.write_str(fmt!("%s {", name)); - f(); - self.wr.write_str(~"}"); - } - - fn emit_field(&self, name: &str, idx: uint, f: &fn()) { - if idx > 0u { self.wr.write_str(~", "); } - self.wr.write_str(name); - self.wr.write_str(~": "); - f(); - } - - fn emit_tup(&self, _len: uint, f: &fn()) { - self.wr.write_str(~"("); - f(); - self.wr.write_str(~")"); - } - - fn emit_tup_elt(&self, idx: uint, f: &fn()) { - if idx > 0u { self.wr.write_str(~", "); } - f(); - } - - fn emit_option(&self, f: &fn()) { - f(); - } - - fn emit_option_none(&self) { - self.wr.write_str("None"); - } - - fn emit_option_some(&self, f: &fn()) { - self.wr.write_str("Some("); - f(); - self.wr.write_char(')'); - } -} diff --git a/src/libstd/std.rc b/src/libstd/std.rc index a0ab714de05f..b28e2f0ab6df 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -88,7 +88,6 @@ pub mod md4; pub mod tempfile; pub mod term; pub mod time; -pub mod prettyprint; pub mod arena; pub mod par; pub mod cmp; diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 1a8ad446c795..137213d815f6 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -22,21 +22,9 @@ use EBWriter = std::ebml::writer; use core::cmp::Eq; use core::io::Writer; use std::ebml; -use std::prettyprint; use std::serialize::{Encodable, Decodable}; use std::time; -fn test_prettyprint>( - a: &A, - expected: &~str -) { - let s = do io::with_str_writer |w| { - a.encode(&prettyprint::Serializer(w)) - }; - debug!("s == %?", s); - fail_unless!(s == *expected); -} - fn test_ebml + @@ -149,36 +137,27 @@ enum CLike { A, B, C } pub fn main() { let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u))); - test_prettyprint(a, &~"Plus(@Minus(@Val(3u), @Val(10u)), \ - @Plus(@Val(22u), @Val(5u)))"); test_ebml(a); let a = &Spanned {lo: 0u, hi: 5u, node: 22u}; - test_prettyprint(a, &~"Spanned {lo: 0u, hi: 5u, node: 22u}"); test_ebml(a); let a = &Point {x: 3u, y: 5u}; - test_prettyprint(a, &~"Point {x: 3u, y: 5u}"); test_ebml(a); let a = &@[1u, 2u, 3u]; - test_prettyprint(a, &~"@[1u, 2u, 3u]"); test_ebml(a); let a = &Top(22u); - test_prettyprint(a, &~"Top(22u)"); test_ebml(a); let a = &Bottom(222u); - test_prettyprint(a, &~"Bottom(222u)"); test_ebml(a); let a = &A; - test_prettyprint(a, &~"A"); test_ebml(a); let a = &B; - test_prettyprint(a, &~"B"); test_ebml(a); let a = &time::now();