Rename Show to Debug, String to Display
Update reference.md: - derive() no longer supports Zero trait - derive() now supports Copy trait
This commit is contained in:
parent
725cc06464
commit
34afe5e193
9 changed files with 13 additions and 14 deletions
|
@ -2354,8 +2354,8 @@ Supported traits for `derive` are:
|
||||||
* `FromPrimitive`, to create an instance from a numeric primitive.
|
* `FromPrimitive`, to create an instance from a numeric primitive.
|
||||||
* `Hash`, to iterate over the bytes in a data type.
|
* `Hash`, to iterate over the bytes in a data type.
|
||||||
* `Rand`, to create a random instance of a data type.
|
* `Rand`, to create a random instance of a data type.
|
||||||
* `Show`, to format a value using the `{}` formatter.
|
* `Debug`, to format a value using the `{:?}` formatter.
|
||||||
* `Zero`, to create a zero instance of a numeric data type.
|
* `Copy`, for "Plain Old Data" types which can be copied by simply moving bits.
|
||||||
|
|
||||||
### Compiler Features
|
### Compiler Features
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//!
|
//!
|
||||||
//! Consider a situation where we want to log out a value passed to a function.
|
//! Consider a situation where we want to log out a value passed to a function.
|
||||||
//! We know the value we're working on implements Show, but we don't know its
|
//! We know the value we're working on implements Debug, but we don't know its
|
||||||
//! concrete type. We want to give special treatment to certain types: in this
|
//! concrete type. We want to give special treatment to certain types: in this
|
||||||
//! case printing out the length of String values prior to their value.
|
//! case printing out the length of String values prior to their value.
|
||||||
//! We don't know the concrete type of our value at compile time, so we need to
|
//! We don't know the concrete type of our value at compile time, so we need to
|
||||||
|
|
|
@ -195,7 +195,7 @@ pub struct Matches {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type returned when the command line does not conform to the
|
/// The type returned when the command line does not conform to the
|
||||||
/// expected format. Use the `Show` implementation to output detailed
|
/// expected format. Use the `Debug` implementation to output detailed
|
||||||
/// information.
|
/// information.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum Fail {
|
pub enum Fail {
|
||||||
|
@ -545,7 +545,7 @@ impl Fail {
|
||||||
/// Convert a `Fail` enum into an error string.
|
/// Convert a `Fail` enum into an error string.
|
||||||
#[unstable(feature = "rustc_private")]
|
#[unstable(feature = "rustc_private")]
|
||||||
#[deprecated(since = "1.0.0",
|
#[deprecated(since = "1.0.0",
|
||||||
reason = "use `fmt::String` (`{}` format specifier)")]
|
reason = "use `fmt::Display` (`{}` format specifier)")]
|
||||||
pub fn to_err_msg(self) -> String {
|
pub fn to_err_msg(self) -> String {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ impl fmt::Display for Fail {
|
||||||
/// `opt_str`, etc. to interrogate results.
|
/// `opt_str`, etc. to interrogate results.
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Returns `Err(Fail)` on failure: use the `Show` implementation of `Fail` to display
|
/// Returns `Err(Fail)` on failure: use the `Debug` implementation of `Fail` to display
|
||||||
/// information about it.
|
/// information about it.
|
||||||
pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
|
||||||
let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
|
let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
|
||||||
|
|
|
@ -70,7 +70,7 @@ use arena::TypedArena;
|
||||||
use std::borrow::{BorrowFrom, Cow};
|
use std::borrow::{BorrowFrom, Cow};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::hash::{Hash, Writer, SipHasher, Hasher};
|
use std::hash::{Hash, Writer, SipHasher, Hasher};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
//! HTML formatting module
|
//! HTML formatting module
|
||||||
//!
|
//!
|
||||||
//! This module contains a large number of `fmt::String` implementations for
|
//! This module contains a large number of `fmt::Display` implementations for
|
||||||
//! various types in `rustdoc::clean`. These implementations all currently
|
//! various types in `rustdoc::clean`. These implementations all currently
|
||||||
//! assume that HTML output is desired, although it may be possible to redesign
|
//! assume that HTML output is desired, although it may be possible to redesign
|
||||||
//! them in the future to instead emit any format desired.
|
//! them in the future to instead emit any format desired.
|
||||||
|
|
|
@ -1032,7 +1032,7 @@ pub fn as_pretty_json<T>(t: &T) -> AsPrettyJson<T> {
|
||||||
|
|
||||||
impl Json {
|
impl Json {
|
||||||
/// Borrow this json object as a pretty object to generate a pretty
|
/// Borrow this json object as a pretty object to generate a pretty
|
||||||
/// representation for it via `Show`.
|
/// representation for it via `Display`.
|
||||||
pub fn pretty(&self) -> PrettyJson {
|
pub fn pretty(&self) -> PrettyJson {
|
||||||
PrettyJson { inner: self }
|
PrettyJson { inner: self }
|
||||||
}
|
}
|
||||||
|
@ -3540,7 +3540,7 @@ mod tests {
|
||||||
fn test_hashmap_with_enum_key() {
|
fn test_hashmap_with_enum_key() {
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use json;
|
use json;
|
||||||
#[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Show)]
|
#[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Debug)]
|
||||||
enum Enum {
|
enum Enum {
|
||||||
Foo,
|
Foo,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
@ -228,7 +228,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||||
/// ```
|
/// ```
|
||||||
fn into_vec(self) -> Vec<u8>;
|
fn into_vec(self) -> Vec<u8>;
|
||||||
|
|
||||||
/// Returns an object that implements `Show` for printing paths
|
/// Returns an object that implements `Display` for printing paths
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
@ -244,7 +244,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||||
Display{ path: self, filename: false }
|
Display{ path: self, filename: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an object that implements `Show` for printing filenames
|
/// Returns an object that implements `Display` for printing filenames
|
||||||
///
|
///
|
||||||
/// If there is no filename, nothing will be printed.
|
/// If there is no filename, nothing will be printed.
|
||||||
///
|
///
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl<'a> Iterator for SplitPaths<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Show)]
|
#[derive(Debug)]
|
||||||
pub struct JoinPathsError;
|
pub struct JoinPathsError;
|
||||||
|
|
||||||
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
|
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
|
||||||
|
|
|
@ -64,7 +64,6 @@ use parse::token;
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Show;
|
|
||||||
use std::num::Int;
|
use std::num::Int;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue