mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +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:
parent
27d08bfb8d
commit
d752c17029
2 changed files with 10 additions and 10 deletions
|
@ -427,7 +427,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
||||||
debug!("Starts new arg...");
|
debug!("Starts new arg...");
|
||||||
let starts_new_arg = if arg_os.starts_with(b"-") {
|
let starts_new_arg = if arg_os.starts_with(b"-") {
|
||||||
sdebugln!("Yes");
|
sdebugln!("Yes");
|
||||||
!(arg_os.len() == 1)
|
!(arg_os.len_() == 1)
|
||||||
} else {
|
} else {
|
||||||
sdebugln!("No");
|
sdebugln!("No");
|
||||||
false
|
false
|
||||||
|
@ -448,7 +448,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if arg_os.starts_with(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
|
// The user has passed '--' which means only positional args follow no matter
|
||||||
// what they start with
|
// what they start with
|
||||||
pos_only = true;
|
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));
|
needs_val_of = try!(self.parse_long_arg(matcher, &arg_os));
|
||||||
continue;
|
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));
|
needs_val_of = try!(self.parse_short_arg(matcher, &arg_os));
|
||||||
if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
|
if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -972,7 +972,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
|
||||||
debug!("Checking for val...");
|
debug!("Checking for val...");
|
||||||
if let Some(fv) = val {
|
if let Some(fv) = val {
|
||||||
let v = fv.trim_left_matches(b'=');
|
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");
|
sdebugln!("Found Empty - Error");
|
||||||
return Err(Error::empty_value(opt, &*self.create_current_usage(matcher)));
|
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) &&
|
if !arg.is_set(ArgSettings::EmptyValues) &&
|
||||||
val.is_empty() &&
|
val.is_empty_() &&
|
||||||
matcher.contains(&*arg.name()) {
|
matcher.contains(&*arg.name()) {
|
||||||
return Err(Error::empty_value(arg, &*self.create_current_usage(matcher)));
|
return Err(Error::empty_value(arg, &*self.create_current_usage(matcher)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ pub trait OsStrExt2 {
|
||||||
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
|
fn split_at_byte(&self, b: u8) -> (&OsStr, &OsStr);
|
||||||
fn split_at(&self, i: usize) -> (&OsStr, &OsStr);
|
fn split_at(&self, i: usize) -> (&OsStr, &OsStr);
|
||||||
fn trim_left_matches(&self, b: u8) -> &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 contains_byte(&self, b: u8) -> bool;
|
||||||
fn is_empty(&self) -> bool;
|
fn is_empty_(&self) -> bool;
|
||||||
fn split(&self, b: u8) -> OsSplit;
|
fn split(&self, b: u8) -> OsSplit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ impl OsStrExt2 for OsStr {
|
||||||
self.as_bytes().starts_with(s)
|
self.as_bytes().starts_with(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty_(&self) -> bool {
|
||||||
self.as_bytes().is_empty()
|
self.as_bytes().is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ impl OsStrExt2 for OsStr {
|
||||||
for (i, b) in self.as_bytes().iter().enumerate() {
|
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..])); }
|
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 {
|
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..]))
|
(&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()
|
self.as_bytes().len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue