getopts: format failure messages with Show.

This obsoletes the old `to_err_msg` method. Replace

    println!("Error: {}", failure.to_err_msg())

    let string = failure.to_err_msg();

with

    println!("Error: {}", failure)

    let string = failure.to_str();

[breaking-change]
This commit is contained in:
Huon Wilson 2014-06-14 11:11:09 +10:00
parent 3851d68a27
commit 0642cbbde0
7 changed files with 28 additions and 21 deletions

View file

@ -792,7 +792,7 @@ mod test {
let matches =
&match getopts(["--test".to_string()], optgroups().as_slice()) {
Ok(m) => m,
Err(f) => fail!("test_switch_implies_cfg_test: {}", f.to_err_msg())
Err(f) => fail!("test_switch_implies_cfg_test: {}", f)
};
let sessopts = build_session_options(matches);
let sess = build_session(sessopts, None);
@ -809,8 +809,7 @@ mod test {
optgroups().as_slice()) {
Ok(m) => m,
Err(f) => {
fail!("test_switch_implies_cfg_test_unless_cfg_test: {}",
f.to_err_msg());
fail!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
}
};
let sessopts = build_session_options(matches);

View file

@ -205,7 +205,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) {
Ok(m) => m,
Err(f) => {
early_error(f.to_err_msg().as_slice());
early_error(f.to_str().as_slice());
}
};