Skip to content

Commit

Permalink
convert Result<(), OsString> -> Result<(), String>
Browse files Browse the repository at this point in the history
  • Loading branch information
little-dude committed Apr 21, 2018
1 parent 0822e2e commit 45322fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/args/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
#[doc(hidden)]
pub validator: Option<Rc<Fn(String) -> Result<(), String>>>,
#[doc(hidden)]
pub validator_os: Option<Rc<Fn(&OsStr) -> Result<(), OsString>>>,
pub validator_os: Option<Rc<Fn(&OsStr) -> Result<(), String>>>,
#[doc(hidden)]
pub val_delim: Option<char>,
#[doc(hidden)]
Expand Down Expand Up @@ -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")
Expand All @@ -1870,7 +1870,7 @@ impl<'a, 'b> Arg<'a, 'b> {
/// [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
pub fn validator_os<F>(mut self, f: F) -> Self
where
F: Fn(&OsStr) -> Result<(), OsString> + 'static,
F: Fn(&OsStr) -> Result<(), String> + 'static,
{
self.validator_os = Some(Rc::new(f));
self
Expand Down

0 comments on commit 45322fb

Please sign in to comment.