Skip to content

Commit d5186c3

Browse files
committed
Bump to 0.1.7
1 parent 1731544 commit d5186c3

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "glob"
4-
version = "0.1.6"
4+
version = "0.1.7"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
homepage = "https://github.com/rust-lang/glob"

src/lib.rs

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2525
html_root_url = "http://doc.rust-lang.org/glob/")]
2626
#![allow(unstable)]
27+
#![cfg_attr(test, deny(warnings))]
2728

2829
use std::ascii::AsciiExt;
2930
use std::cell::Cell;
@@ -166,8 +167,8 @@ pub fn glob_with(pattern: &str, options: &MatchOptions) -> Result<Paths, Pattern
166167
let scope = root.map(to_scope).unwrap_or_else(|| Path::new("."));
167168

168169
let mut dir_patterns = Vec::new();
169-
let mut components = pattern.slice_from(cmp::min(root_len, pattern.len()))
170-
.split_terminator(is_sep);
170+
let mut components = pattern[cmp::min(root_len, pattern.len())..]
171+
.split_terminator(is_sep);
171172

172173
for component in components {
173174
let compiled = try!(Pattern::new(component));
@@ -191,6 +192,7 @@ pub fn glob_with(pattern: &str, options: &MatchOptions) -> Result<Paths, Pattern
191192
/// This is typically returned when a particular path cannot be read
192193
/// to determine if its contents match the glob pattern. This is possible
193194
/// if the program lacks the permissions, for example.
195+
#[derive(Debug)]
194196
pub struct GlobError {
195197
path: Path,
196198
error: IoError,
@@ -208,15 +210,10 @@ impl GlobError {
208210
}
209211
}
210212

211-
impl fmt::String for GlobError {
213+
impl fmt::Display for GlobError {
212214
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
213-
write!(f, "attempting to read `{:?}` resulted in an error: {}", self.path, self.error)
214-
}
215-
}
216-
217-
impl fmt::Show for GlobError {
218-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
219-
fmt::String::fmt(self, f)
215+
write!(f, "attempting to read `{}` resulted in an error: {}",
216+
self.path.display(), self.error)
220217
}
221218
}
222219

@@ -321,6 +318,8 @@ impl Iterator for Paths {
321318
}
322319

323320
/// A pattern parsing error.
321+
#[derive(Debug)]
322+
#[allow(missing_copy_implementations)]
324323
pub struct PatternError {
325324
/// The approximate character index of where the error occurred.
326325
pub pos: usize,
@@ -329,19 +328,13 @@ pub struct PatternError {
329328
pub msg: &'static str,
330329
}
331330

332-
impl fmt::String for PatternError {
331+
impl fmt::Display for PatternError {
333332
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
334333
write!(f, "Pattern syntax error near position {}: {}",
335334
self.pos, self.msg)
336335
}
337336
}
338337

339-
impl fmt::Show for PatternError {
340-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
341-
fmt::String::fmt(self, f)
342-
}
343-
}
344-
345338
/// A compiled Unix shell style pattern.
346339
///
347340
/// `?` matches any single character
@@ -366,28 +359,21 @@ impl fmt::Show for PatternError {
366359
/// set, so `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively.
367360
/// The `-` character can be specified inside a character sequence pattern by
368361
/// placing it at the start or the end, e.g. `[abc-]`.
369-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
362+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
370363
pub struct Pattern {
371364
original: String,
372365
tokens: Vec<PatternToken>,
373366
is_recursive: bool,
374367
}
375368

376369
/// Show the original glob pattern.
377-
impl fmt::String for Pattern {
370+
impl fmt::Display for Pattern {
378371
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
379372
self.original.fmt(f)
380373
}
381374
}
382375

383-
/// Show the original glob pattern.
384-
impl fmt::Show for Pattern {
385-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
386-
fmt::String::fmt(self, f)
387-
}
388-
}
389-
390-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
376+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
391377
enum PatternToken {
392378
Char(char),
393379
AnyChar,
@@ -397,7 +383,7 @@ enum PatternToken {
397383
AnyExcept(Vec<CharSpecifier> )
398384
}
399385

400-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
386+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
401387
enum CharSpecifier {
402388
SingleChar(char),
403389
CharRange(char, char)
@@ -497,21 +483,21 @@ impl Pattern {
497483
'[' => {
498484

499485
if i <= chars.len() - 4 && chars[i + 1] == '!' {
500-
match chars.slice_from(i + 3).position_elem(&']') {
486+
match chars[i + 3..].position_elem(&']') {
501487
None => (),
502488
Some(j) => {
503-
let chars = chars.slice(i + 2, i + 3 + j);
489+
let chars = &chars[i + 2 .. i + 3 + j];
504490
let cs = parse_char_specifiers(chars);
505491
tokens.push(AnyExcept(cs));
506492
i += j + 4;
507493
continue;
508494
}
509495
}
510496
} else if i <= chars.len() - 3 && chars[i + 1] != '!' {
511-
match chars.slice_from(i + 2).position_elem(&']') {
497+
match chars[i + 2..].position_elem(&']') {
512498
None => (),
513499
Some(j) => {
514-
let cs = parse_char_specifiers(chars.slice(i + 1, i + 2 + j));
500+
let cs = parse_char_specifiers(&chars[i + 1 .. i + 2 + j]);
515501
tokens.push(AnyWithin(cs));
516502
i += j + 3;
517503
continue;
@@ -619,7 +605,7 @@ impl Pattern {
619605
&& is_sep(prev_char.get().unwrap_or('/')))
620606
};
621607

622-
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {
608+
for (ti, token) in self.tokens[i..].iter().enumerate() {
623609
match *token {
624610
AnySequence | AnyRecursiveSequence => {
625611
loop {
@@ -918,7 +904,7 @@ mod test {
918904
let err = next.unwrap();
919905
assert!(err.is_err());
920906

921-
let err = err.unwrap_err();
907+
let err = err.err().unwrap();
922908
assert!(*err.path() == Path::new("/root"));
923909
assert!(err.error().kind == ::std::io::IoErrorKind::PermissionDenied);
924910
}

0 commit comments

Comments
 (0)