2
0
Fork 0
mirror of https://github.com/clap-rs/clap synced 2024-12-14 14:52:33 +00:00

rename OsStrExt2::{is_empty,len} to {is_empty_,len_}

OsStr recently gained unstable inherent methods with the same name. This rename
makes sure we don't call the inherent methods but the methods provided by this
extension trait.
This commit is contained in:
Jorge Aparicio 2016-02-21 11:18:26 -05:00
parent 27d08bfb8d
commit d752c17029
2 changed files with 10 additions and 10 deletions

View file

@ -427,7 +427,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
debug!("Starts new arg...");
let starts_new_arg = if arg_os.starts_with(b"-") {
sdebugln!("Yes");
!(arg_os.len() == 1)
!(arg_os.len_() == 1)
} else {
sdebugln!("No");
false
@ -448,7 +448,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
}
}
if arg_os.starts_with(b"--") {
if arg_os.len() == 2 {
if arg_os.len_() == 2 {
// The user has passed '--' which means only positional args follow no matter
// what they start with
pos_only = true;
@ -457,7 +457,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
needs_val_of = try!(self.parse_long_arg(matcher, &arg_os));
continue;
} else if arg_os.starts_with(b"-") && arg_os.len() != 1 {
} else if arg_os.starts_with(b"-") && arg_os.len_() != 1 {
needs_val_of = try!(self.parse_short_arg(matcher, &arg_os));
if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
continue;
@ -972,7 +972,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
debug!("Checking for val...");
if let Some(fv) = val {
let v = fv.trim_left_matches(b'=');
if !opt.is_set(ArgSettings::EmptyValues) && v.len() == 0 {
if !opt.is_set(ArgSettings::EmptyValues) && v.len_() == 0 {
sdebugln!("Found Empty - Error");
return Err(Error::empty_value(opt, &*self.create_current_usage(matcher)));
}
@ -1043,7 +1043,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
}
}
if !arg.is_set(ArgSettings::EmptyValues) &&
val.is_empty() &&
val.is_empty_() &&
matcher.contains(&*arg.name()) {
return Err(Error::empty_value(arg, &*self.create_current_usage(matcher)));
}

View file

@ -17,9 +17,9 @@ pub trait OsStrExt2 {
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
fn split_at(&self, i: usize) -> (&OsStr, &OsStr);
fn trim_left_matches(&self, b: u8) -> &OsStr;
fn len(&self) -> usize;
fn len_(&self) -> usize;
fn contains_byte(&self, b: u8) -> bool;
fn is_empty(&self) -> bool;
fn is_empty_(&self) -> bool;
fn split(&self, b: u8) -> OsSplit;
}
@ -39,7 +39,7 @@ impl OsStrExt2 for OsStr {
self.as_bytes().starts_with(s)
}
fn is_empty(&self) -> bool {
fn is_empty_(&self) -> bool {
self.as_bytes().is_empty()
}
@ -54,7 +54,7 @@ impl OsStrExt2 for OsStr {
for (i, b) in self.as_bytes().iter().enumerate() {
if b == &byte { return (&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i+1..])); }
}
(&*self, &OsStr::from_bytes(&self.as_bytes()[self.len()..self.len()]))
(&*self, &OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()]))
}
fn trim_left_matches(&self, byte: u8) -> &OsStr {
@ -68,7 +68,7 @@ impl OsStrExt2 for OsStr {
(&OsStr::from_bytes(&self.as_bytes()[..i]), &OsStr::from_bytes(&self.as_bytes()[i..]))
}
fn len(&self) -> usize {
fn len_(&self) -> usize {
self.as_bytes().len()
}