Skip to content

Commit 210d9a1

Browse files
authored
Merge pull request #9 from imnotpoz/main
impl Display for Argument
2 parents 0d5cf75 + abacf3e commit 210d9a1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ impl<'a> Argument<'a> {
173173
}
174174
}
175175

176+
impl Display for Argument<'_> {
177+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
178+
use Argument::{Long, Short, Stdio, Value};
179+
180+
match self {
181+
Long(s) => write!(f, "--{s}"),
182+
Short(ch) => write!(f, "-{ch}"),
183+
Value(cow) => write!(f, "{cow}"),
184+
Stdio => write!(f, "-"),
185+
}
186+
}
187+
}
188+
176189
/// A stateful command-line argument parser.
177190
///
178191
/// The `Parser` processes arguments one at a time using an iterator-based approach,

0 commit comments

Comments
 (0)