Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Update Show/String to Debug/Display #85

Merged
merged 2 commits into from
Jan 23, 2015
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
2 changes: 1 addition & 1 deletion docopt_macros/examples/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
extern crate docopt;
#[plugin] #[no_link] extern crate docopt_macros;

docopt!(Args derive Show, "
docopt!(Args derive Debug, "
Usage: cp [options] <src> <dst>
cp [options] <src>... <dir>
cp --help
Expand Down
2 changes: 1 addition & 1 deletion docopt_macros/examples/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
extern crate docopt;
#[plugin] #[no_link] extern crate docopt_macros;

docopt!(pub Args derive Show, "
docopt!(pub Args derive Debug, "
Naval Fate.

Usage:
Expand Down
6 changes: 3 additions & 3 deletions docopt_macros/examples/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
extern crate docopt;
#[plugin] #[no_link] extern crate docopt_macros;

docopt!(Args derive Show, "
docopt!(Args derive Debug, "
Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
rustc (--help | --version)

Expand All @@ -19,10 +19,10 @@ Options:
--opt-level LEVEL Optimize with possible levels 0-3.
", flag_opt_level: Option<OptLevel>, flag_emit: Option<Emit>);

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
enum Emit { Asm, Ir, Bc, Obj, Link }

#[derive(Show)]
#[derive(Debug)]
enum OptLevel { Zero, One, Two, Three }

impl rustc_serialize::Decodable for OptLevel {
Expand Down
4 changes: 2 additions & 2 deletions examples/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ Some common cargo commands are:
See 'cargo help <command>' for more information on a specific command.
";

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
struct Args {
arg_command: Command,
arg_args: Vec<String>,
flag_list: bool,
flag_verbose: bool,
}

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
enum Command {
Build, Clean, Doc, New, Run, Test, Bench, Update,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Options:
-a, --archive Copy everything.
";

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
struct Args {
arg_source: Vec<String>,
arg_dest: String,
Expand Down
2 changes: 1 addition & 1 deletion examples/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Options:
--drifting Drifting mine.
";

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
struct Args {
flag_speed: isize,
flag_drifting: bool,
Expand Down
2 changes: 1 addition & 1 deletion examples/verbose_multiple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Options:
-v, --verbose Show extra log output.
";

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
struct Args {
arg_source: Vec<String>,
arg_dest: String,
Expand Down
17 changes: 8 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@
//! // This is easy. The decoder will automatically restrict values to
//! // strings that match one of the enum variants.
//! #[derive(RustcDecodable)]
//! # #[derive(PartialEq, Show)]
//! # #[derive(Debug, PartialEq)]
//! enum Emit { Asm, Ir, Bc, Obj, Link }
//!
//! // This one is harder because we want the user to specify an integer,
//! // but restrict it to a specific range. So we implement `Decodable`
//! // ourselves.
//! # #[derive(PartialEq, Show)]
//! # #[derive(Debug, PartialEq)]
//! enum OptLevel { Zero, One, Two, Three }
//!
//! impl rustc_serialize::Decodable for OptLevel {
Expand Down Expand Up @@ -281,7 +281,7 @@ macro_rules! regex(
/// .and_then(|d| d.parse())
/// .unwrap_or_else(|e| e.exit());
/// ```
#[derive(Show)]
#[derive(Debug)]
pub enum Error {
/// Parsing the usage string failed.
///
Expand Down Expand Up @@ -356,7 +356,7 @@ impl Error {
}
}

impl fmt::String for Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
WithProgramUsage(ref other, ref usage) => {
Expand Down Expand Up @@ -389,7 +389,6 @@ impl StdError for Error {
}
}

fn detail(&self) -> Option<String> { Some(self.to_string()) }
fn cause(&self) -> Option<&StdError> {
match *self {
WithProgramUsage(ref cause, _) => Some(&**cause as &StdError),
Expand Down Expand Up @@ -418,7 +417,7 @@ impl<'a> StrAllocating for &'a str {
/// The main Docopt type, which is constructed with a Docopt usage string.
///
/// This can be used to match command line arguments to produce a `ArgvMap`.
#[derive(Clone, Show)]
#[derive(Clone, Debug)]
pub struct Docopt {
p: Parser,
argv: Option<Vec<String>>,
Expand Down Expand Up @@ -741,7 +740,7 @@ impl ArgvMap {
}
}

impl fmt::Show for ArgvMap {
impl fmt::Debug for ArgvMap {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.len() == 0 {
return write!(f, "{{EMPTY}}");
Expand Down Expand Up @@ -776,7 +775,7 @@ impl fmt::Show for ArgvMap {
///
/// The various `as_{bool,count,str,vec}` methods provide convenient access
/// to values without destructuring manually.
#[derive(Clone, PartialEq, Show)]
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
/// A boolean value from a flag that has no argument.
///
Expand Down Expand Up @@ -879,7 +878,7 @@ pub struct Decoder {
stack: Vec<DecoderItem>,
}

#[derive(Show)]
#[derive(Debug)]
struct DecoderItem {
key: String,
struct_field: String,
Expand Down
18 changes: 9 additions & 9 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Parser {
}
}

impl fmt::Show for Parser {
impl fmt::Debug for Parser {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn sorted<T: Ord>(mut xs: Vec<T>) -> Vec<T> {
xs.sort(); xs
Expand Down Expand Up @@ -585,7 +585,7 @@ impl<'a> PatParser<'a> {
}
}

#[derive(Clone, Show)]
#[derive(Clone, Debug)]
enum Pattern {
Alternates(Vec<Pattern>),
Sequence(Vec<Pattern>),
Expand All @@ -594,15 +594,15 @@ enum Pattern {
PatAtom(Atom),
}

#[derive(PartialEq, Eq, Ord, Hash, Clone, Show)]
#[derive(PartialEq, Eq, Ord, Hash, Clone, Debug)]
pub enum Atom {
Short(char),
Long(String),
Command(String),
Positional(String),
}

#[derive(Clone, Show)]
#[derive(Clone, Debug)]
pub struct Options {
/// Set to true if this atom is ever repeated in any context.
/// For positional arguments, non-argument flags and commands, repetition
Expand All @@ -620,7 +620,7 @@ pub struct Options {
pub is_desc: bool,
}

#[derive(Clone, Show, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum Argument {
Zero,
One(Option<String>), // optional default value
Expand Down Expand Up @@ -758,7 +758,7 @@ impl PartialOrd for Atom {
}
}

impl fmt::String for Atom {
impl fmt::Display for Atom {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Short(c) => write!(f, "-{}", c),
Expand Down Expand Up @@ -809,7 +809,7 @@ pub struct Argv<'a> {
options_first: bool,
}

#[derive(Clone, Show)]
#[derive(Clone, Debug)]
struct ArgvToken {
atom: Atom,
arg: Option<String>,
Expand Down Expand Up @@ -929,7 +929,7 @@ impl<'a> Argv<'a> {
}
}

impl<'a> fmt::Show for Argv<'a> {
impl<'a> fmt::Debug for Argv<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
try!(writeln!(f, "Positional: {:?}", self.positional));
try!(writeln!(f, "Flags: {:?}", self.flags));
Expand All @@ -942,7 +942,7 @@ struct Matcher<'a, 'b:'a> {
argv: &'a Argv<'b>,
}

#[derive(Clone, PartialEq, Show)]
#[derive(Clone, Debug, PartialEq)]
struct MState {
argvi: usize, // index into Argv.positional
counts: HashMap<Atom, usize>, // flags remaining for pattern consumption
Expand Down
4 changes: 2 additions & 2 deletions src/synonym.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::collections::hash_map::{Hasher, Iter, Keys};
use std::fmt::Show;
use std::fmt::Debug;
use std::hash::Hash;
use std::iter::FromIterator;
use std::mem;
Expand Down Expand Up @@ -99,7 +99,7 @@ impl<K: Eq + Hash<Hasher> + Clone, V> FromIterator<(K, V)> for SynonymMap<K, V>
}
}

impl<K: Eq + Hash<Hasher> + Show, V: Show> Show for SynonymMap<K, V> {
impl<K: Eq + Hash<Hasher> + Debug, V: Debug> Debug for SynonymMap<K, V> {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
try!(self.vals.fmt(f));
write!(f, " (synomyns: {:?})", self.syns)
Expand Down
2 changes: 1 addition & 1 deletion src/wordlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Which will only include 'a', 'b' and 'c' in the wordlist if
'your-command --help' contains a positional argument named 'arg'.
";

#[derive(RustcDecodable, Show)]
#[derive(Debug, RustcDecodable)]
struct Args {
arg_name: Vec<String>,
arg_possibles: Vec<String>,
Expand Down