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

Commit 8b67d6b

Browse files
committed
Merge pull request #85 from ianbollinger/debug-and-display
Update Show/String to Debug/Display
2 parents 9801d52 + a73c12a commit 8b67d6b

File tree

11 files changed

+30
-31
lines changed

11 files changed

+30
-31
lines changed

docopt_macros/examples/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
55
extern crate docopt;
66
#[plugin] #[no_link] extern crate docopt_macros;
77

8-
docopt!(Args derive Show, "
8+
docopt!(Args derive Debug, "
99
Usage: cp [options] <src> <dst>
1010
cp [options] <src>... <dir>
1111
cp --help

docopt_macros/examples/macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
55
extern crate docopt;
66
#[plugin] #[no_link] extern crate docopt_macros;
77

8-
docopt!(pub Args derive Show, "
8+
docopt!(pub Args derive Debug, "
99
Naval Fate.
1010
1111
Usage:

docopt_macros/examples/rustc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate "rustc-serialize" as rustc_serialize;
55
extern crate docopt;
66
#[plugin] #[no_link] extern crate docopt_macros;
77

8-
docopt!(Args derive Show, "
8+
docopt!(Args derive Debug, "
99
Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
1010
rustc (--help | --version)
1111
@@ -19,10 +19,10 @@ Options:
1919
--opt-level LEVEL Optimize with possible levels 0-3.
2020
", flag_opt_level: Option<OptLevel>, flag_emit: Option<Emit>);
2121

22-
#[derive(RustcDecodable, Show)]
22+
#[derive(Debug, RustcDecodable)]
2323
enum Emit { Asm, Ir, Bc, Obj, Link }
2424

25-
#[derive(Show)]
25+
#[derive(Debug)]
2626
enum OptLevel { Zero, One, Two, Three }
2727

2828
impl rustc_serialize::Decodable for OptLevel {

examples/cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ Some common cargo commands are:
3030
See 'cargo help <command>' for more information on a specific command.
3131
";
3232

33-
#[derive(RustcDecodable, Show)]
33+
#[derive(Debug, RustcDecodable)]
3434
struct Args {
3535
arg_command: Command,
3636
arg_args: Vec<String>,
3737
flag_list: bool,
3838
flag_verbose: bool,
3939
}
4040

41-
#[derive(RustcDecodable, Show)]
41+
#[derive(Debug, RustcDecodable)]
4242
enum Command {
4343
Build, Clean, Doc, New, Run, Test, Bench, Update,
4444
}

examples/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Options:
1212
-a, --archive Copy everything.
1313
";
1414

15-
#[derive(RustcDecodable, Show)]
15+
#[derive(Debug, RustcDecodable)]
1616
struct Args {
1717
arg_source: Vec<String>,
1818
arg_dest: String,

examples/decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Options:
2222
--drifting Drifting mine.
2323
";
2424

25-
#[derive(RustcDecodable, Show)]
25+
#[derive(Debug, RustcDecodable)]
2626
struct Args {
2727
flag_speed: isize,
2828
flag_drifting: bool,

examples/verbose_multiple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Options:
1919
-v, --verbose Show extra log output.
2020
";
2121

22-
#[derive(RustcDecodable, Show)]
22+
#[derive(Debug, RustcDecodable)]
2323
struct Args {
2424
arg_source: Vec<String>,
2525
arg_dest: String,

src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@
126126
//! // This is easy. The decoder will automatically restrict values to
127127
//! // strings that match one of the enum variants.
128128
//! #[derive(RustcDecodable)]
129-
//! # #[derive(PartialEq, Show)]
129+
//! # #[derive(Debug, PartialEq)]
130130
//! enum Emit { Asm, Ir, Bc, Obj, Link }
131131
//!
132132
//! // This one is harder because we want the user to specify an integer,
133133
//! // but restrict it to a specific range. So we implement `Decodable`
134134
//! // ourselves.
135-
//! # #[derive(PartialEq, Show)]
135+
//! # #[derive(Debug, PartialEq)]
136136
//! enum OptLevel { Zero, One, Two, Three }
137137
//!
138138
//! impl rustc_serialize::Decodable for OptLevel {
@@ -281,7 +281,7 @@ macro_rules! regex(
281281
/// .and_then(|d| d.parse())
282282
/// .unwrap_or_else(|e| e.exit());
283283
/// ```
284-
#[derive(Show)]
284+
#[derive(Debug)]
285285
pub enum Error {
286286
/// Parsing the usage string failed.
287287
///
@@ -356,7 +356,7 @@ impl Error {
356356
}
357357
}
358358

359-
impl fmt::String for Error {
359+
impl fmt::Display for Error {
360360
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
361361
match *self {
362362
WithProgramUsage(ref other, ref usage) => {
@@ -389,7 +389,6 @@ impl StdError for Error {
389389
}
390390
}
391391

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

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

882-
#[derive(Show)]
881+
#[derive(Debug)]
883882
struct DecoderItem {
884883
key: String,
885884
struct_field: String,

src/parse.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl Parser {
291291
}
292292
}
293293

294-
impl fmt::Show for Parser {
294+
impl fmt::Debug for Parser {
295295
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
296296
fn sorted<T: Ord>(mut xs: Vec<T>) -> Vec<T> {
297297
xs.sort(); xs
@@ -585,7 +585,7 @@ impl<'a> PatParser<'a> {
585585
}
586586
}
587587

588-
#[derive(Clone, Show)]
588+
#[derive(Clone, Debug)]
589589
enum Pattern {
590590
Alternates(Vec<Pattern>),
591591
Sequence(Vec<Pattern>),
@@ -594,15 +594,15 @@ enum Pattern {
594594
PatAtom(Atom),
595595
}
596596

597-
#[derive(PartialEq, Eq, Ord, Hash, Clone, Show)]
597+
#[derive(PartialEq, Eq, Ord, Hash, Clone, Debug)]
598598
pub enum Atom {
599599
Short(char),
600600
Long(String),
601601
Command(String),
602602
Positional(String),
603603
}
604604

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

623-
#[derive(Clone, Show, PartialEq)]
623+
#[derive(Clone, Debug, PartialEq)]
624624
pub enum Argument {
625625
Zero,
626626
One(Option<String>), // optional default value
@@ -758,7 +758,7 @@ impl PartialOrd for Atom {
758758
}
759759
}
760760

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

812-
#[derive(Clone, Show)]
812+
#[derive(Clone, Debug)]
813813
struct ArgvToken {
814814
atom: Atom,
815815
arg: Option<String>,
@@ -929,7 +929,7 @@ impl<'a> Argv<'a> {
929929
}
930930
}
931931

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

945-
#[derive(Clone, PartialEq, Show)]
945+
#[derive(Clone, Debug, PartialEq)]
946946
struct MState {
947947
argvi: usize, // index into Argv.positional
948948
counts: HashMap<Atom, usize>, // flags remaining for pattern consumption

src/synonym.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22
use std::collections::hash_map::{Hasher, Iter, Keys};
3-
use std::fmt::Show;
3+
use std::fmt::Debug;
44
use std::hash::Hash;
55
use std::iter::FromIterator;
66
use std::mem;
@@ -99,7 +99,7 @@ impl<K: Eq + Hash<Hasher> + Clone, V> FromIterator<(K, V)> for SynonymMap<K, V>
9999
}
100100
}
101101

102-
impl<K: Eq + Hash<Hasher> + Show, V: Show> Show for SynonymMap<K, V> {
102+
impl<K: Eq + Hash<Hasher> + Debug, V: Debug> Debug for SynonymMap<K, V> {
103103
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
104104
try!(self.vals.fmt(f));
105105
write!(f, " (synomyns: {:?})", self.syns)

0 commit comments

Comments
 (0)