Skip to content

Commit 57a7955

Browse files
committed
Update Show/String to Debug/Display
This commit replaces usage of the Show and fmt::String traits with the Debug and Display traits. This was required to fix breaking changes introduced by rust-lang/rust#21457. Additionally, the superfluous `detail` method on `docopt::Error` was removed as it no longer exists in the trait. Also, hi!
1 parent 9801d52 commit 57a7955

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

src/lib.rs

+8-9
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

+9-9
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

+2-2
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)

src/wordlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Which will only include 'a', 'b' and 'c' in the wordlist if
4545
'your-command --help' contains a positional argument named 'arg'.
4646
";
4747

48-
#[derive(RustcDecodable, Show)]
48+
#[derive(Debug, RustcDecodable)]
4949
struct Args {
5050
arg_name: Vec<String>,
5151
arg_possibles: Vec<String>,

0 commit comments

Comments
 (0)