diff --git a/src/app/validator.rs b/src/app/validator.rs index 0b897e567e8..4446e990f8c 100644 --- a/src/app/validator.rs +++ b/src/app/validator.rs @@ -135,7 +135,7 @@ impl<'a, 'b, 'c, 'z> Validator<'a, 'b, 'c, 'z> { sdebugln!("error"); return Err(Error::value_validation( Some(arg), - (*e).to_string_lossy().to_string(), + (*e).to_string(), self.0.app.color(), )); } else { diff --git a/src/args/arg.rs b/src/args/arg.rs index d827826fdbb..19f27be049a 100644 --- a/src/args/arg.rs +++ b/src/args/arg.rs @@ -89,7 +89,7 @@ where #[doc(hidden)] pub validator: Option Result<(), String>>>, #[doc(hidden)] - pub validator_os: Option Result<(), OsString>>>, + pub validator_os: Option Result<(), String>>>, #[doc(hidden)] pub val_delim: Option, #[doc(hidden)] @@ -1848,9 +1848,9 @@ impl<'a, 'b> Arg<'a, 'b> { /// # use clap::{App, Arg}; /// # use std::ffi::{OsStr, OsString}; /// # use std::os::unix::ffi::OsStrExt; - /// fn has_ampersand(v: &OsStr) -> Result<(), OsString> { + /// fn has_ampersand(v: &OsStr) -> Result<(), String> { /// if v.as_bytes().iter().any(|b| *b == b'&') { return Ok(()); } - /// Err(OsString::from("The value did not contain the required & sigil")) + /// Err(String::from("The value did not contain the required & sigil")) /// } /// let res = App::new("prog") /// .arg(Arg::with_name("file") @@ -1869,7 +1869,8 @@ impl<'a, 'b> Arg<'a, 'b> { /// [`Err(String)`]: https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err /// [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html pub fn validator_os(mut self, f: F) -> Self - where F: Fn(&OsStr) -> Result + 'static + where + F: Fn(&OsStr) -> Result + 'static, { self.validator_os = Some(Rc::new(move |s| f(s).map(|_| ()))); self