about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-01-30 00:46:37 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2014-02-02 12:55:15 +1100
commit003ce502350ed1e374b740ee2d719e500c165615 (patch)
treee253c6227b70a139539529bbdbb4d348cb1f64c3 /src/libstd
parent2bcd951749b67402ccaa31f1bb0349656f880fe2 (diff)
downloadrust-003ce502350ed1e374b740ee2d719e500c165615.tar.gz
rust-003ce502350ed1e374b740ee2d719e500c165615.zip
std: rename fmt::Default to `Show`.
This is a better name with which to have a #[deriving] mode.

Decision in:
https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/fmt/mod.rs35
-rw-r--r--src/libstd/io/process.rs2
-rw-r--r--src/libstd/option.rs2
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/path/mod.rs6
-rw-r--r--src/libstd/result.rs2
6 files changed, 34 insertions, 15 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 13e6d808095..435e5568b8f 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -149,13 +149,13 @@ The current mapping of types to traits is:
 * `f` ⇒ `Float`
 * `e` ⇒ `LowerExp`
 * `E` ⇒ `UpperExp`
-* *nothing* ⇒ `Default`
+* *nothing* ⇒ `Show`
 
 What this means is that any type of argument which implements the
 `std::fmt::Binary` trait can then be formatted with `{:t}`. Implementations are
 provided for these traits for a number of primitive types by the standard
 library as well. If no format is specified (as in `{}` or `{:6}`), then the
-format trait used is the `Default` trait. This is one of the more commonly
+format trait used is the `Show` trait. This is one of the more commonly
 implemented traits when formatting a custom type.
 
 When implementing a format trait for your own time, you will have to implement a
@@ -186,7 +186,7 @@ struct Vector2D {
     y: int,
 }
 
-impl fmt::Default for Vector2D {
+impl fmt::Show for Vector2D {
     fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) {
         // The `f.buf` value is of the type `&mut io::Writer`, which is what th
         // write! macro is expecting. Note that this formatting ignores the
@@ -468,6 +468,7 @@ will look like `"\\{"`.
 
 */
 
+#[cfg(not(stage0))]
 use prelude::*;
 
 use cast;
@@ -479,6 +480,24 @@ use repr;
 use util;
 use vec;
 
+// SNAP b6400f9 this is just because the `prelude::*` import above
+// includes default::Default, so the reexport doesn't work.
+#[cfg(stage0)]
+pub use Default = fmt::Show; // export required for `format!()` etc.
+
+#[cfg(stage0)]
+use container::Container;
+#[cfg(stage0)]
+use iter::{Iterator, range};
+#[cfg(stage0)]
+use option::{Option,Some,None};
+#[cfg(stage0)]
+use vec::ImmutableVector;
+#[cfg(stage0)]
+use str::StrSlice;
+#[cfg(stage0)]
+use num::Signed;
+
 pub mod parse;
 pub mod rt;
 
@@ -542,7 +561,7 @@ pub struct Arguments<'a> {
 /// to this trait. There is not an explicit way of selecting this trait to be
 /// used for formatting, it is only if no other format is specified.
 #[allow(missing_doc)]
-pub trait Default { fn fmt(&Self, &mut Formatter); }
+pub trait Show { fn fmt(&Self, &mut Formatter); }
 
 /// Format trait for the `b` character
 #[allow(missing_doc)]
@@ -1148,10 +1167,10 @@ impl<T> Pointer for *mut T {
     fn fmt(t: &*mut T, f: &mut Formatter) { Pointer::fmt(&(*t as *T), f) }
 }
 
-// Implementation of Default for various core types
+// Implementation of Show for various core types
 
 macro_rules! delegate(($ty:ty to $other:ident) => {
-    impl<'a> Default for $ty {
+    impl<'a> Show for $ty {
         fn fmt(me: &$ty, f: &mut Formatter) {
             $other::fmt(me, f)
         }
@@ -1174,10 +1193,10 @@ delegate!(char to Char)
 delegate!(f32 to Float)
 delegate!(f64 to Float)
 
-impl<T> Default for *T {
+impl<T> Show for *T {
     fn fmt(me: &*T, f: &mut Formatter) { Pointer::fmt(me, f) }
 }
-impl<T> Default for *mut T {
+impl<T> Show for *mut T {
     fn fmt(me: &*mut T, f: &mut Formatter) { Pointer::fmt(me, f) }
 }
 
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index c3fb3e97edf..6a10f24916f 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -91,7 +91,7 @@ pub enum ProcessExit {
     ExitSignal(int),
 }
 
-impl fmt::Default for ProcessExit {
+impl fmt::Show for ProcessExit {
     /// Format a ProcessExit enum, to nicely present the information.
     fn fmt(obj: &ProcessExit, f: &mut fmt::Formatter) {
         match *obj {
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index fd5f3a233e6..83cedd92a3f 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -380,7 +380,7 @@ impl<T: Default> Option<T> {
 // Trait implementations
 /////////////////////////////////////////////////////////////////////////////
 
-impl<T: fmt::Default> fmt::Default for Option<T> {
+impl<T: fmt::Show> fmt::Show for Option<T> {
     #[inline]
     fn fmt(s: &Option<T>, f: &mut fmt::Formatter) {
         match *s {
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 457d58ae464..0ea1c7510a1 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -928,7 +928,7 @@ pub enum MapError {
     ErrMapViewOfFile(uint)
 }
 
-impl fmt::Default for MapError {
+impl fmt::Show for MapError {
     fn fmt(val: &MapError, out: &mut fmt::Formatter) {
         let str = match *val {
             ErrFdNotAvail => "fd not available for reading or writing",
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index c5482811a94..86f96a1075b 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -198,14 +198,14 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
     /// Converts the Path into an owned byte vector
     fn into_vec(self) -> ~[u8];
 
-    /// Returns an object that implements `fmt::Default` for printing paths
+    /// Returns an object that implements `Show` for printing paths
     ///
     /// This will print the equivalent of `to_display_str()` when used with a {} format parameter.
     fn display<'a>(&'a self) -> Display<'a, Self> {
         Display{ path: self, filename: false }
     }
 
-    /// Returns an object that implements `fmt::Default` for printing filenames
+    /// Returns an object that implements `Show` for printing filenames
     ///
     /// This will print the equivalent of `to_filename_display_str()` when used with a {}
     /// format parameter. If there is no filename, nothing will be printed.
@@ -532,7 +532,7 @@ pub struct Display<'a, P> {
     priv filename: bool
 }
 
-impl<'a, P: GenericPath> fmt::Default for Display<'a, P> {
+impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
     fn fmt(d: &Display<P>, f: &mut fmt::Formatter) {
         d.with_str(|s| f.pad(s))
     }
diff --git a/src/libstd/result.rs b/src/libstd/result.rs
index 4783c983d00..cc8fdeaccfe 100644
--- a/src/libstd/result.rs
+++ b/src/libstd/result.rs
@@ -206,7 +206,7 @@ impl<T, E> Result<T, E> {
 // Trait implementations
 /////////////////////////////////////////////////////////////////////////////
 
-impl<T: fmt::Default, E: fmt::Default> fmt::Default for Result<T, E> {
+impl<T: fmt::Show, E: fmt::Show> fmt::Show for Result<T, E> {
     #[inline]
     fn fmt(s: &Result<T, E>, f: &mut fmt::Formatter) {
         match *s {