Skip to content

Commit eb6d079

Browse files
committed
Bump to 0.2.3
1 parent e0f9073 commit eb6d079

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
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.2.2"
4+
version = "0.2.3"
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: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
html_root_url = "http://doc.rust-lang.org/glob/")]
2626
#![cfg_attr(test, deny(warnings))]
2727
#![cfg_attr(all(test, windows), feature(std_misc))]
28-
#![feature(path, io, core, collections, unicode)]
28+
#![feature(path, io)]
2929

3030
use std::ascii::AsciiExt;
3131
use std::cell::Cell;
@@ -251,7 +251,7 @@ impl Iterator for Paths {
251251
// Shouldn't happen, but we're using -1 as a special index.
252252
assert!(self.dir_patterns.len() < -1 as usize);
253253

254-
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
254+
fill_todo(&mut self.todo, &self.dir_patterns,
255255
0, &scope, &self.options);
256256
}
257257
}
@@ -285,7 +285,7 @@ impl Iterator for Paths {
285285
// the path is a directory, so it's a match
286286
if is_dir(&path) {
287287
// push this directory's contents
288-
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
288+
fill_todo(&mut self.todo, &self.dir_patterns,
289289
next, &path, &self.options);
290290

291291
// pattern ends in recursive pattern, so return this
@@ -324,7 +324,7 @@ impl Iterator for Paths {
324324
return Some(Ok(path));
325325
}
326326
} else {
327-
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
327+
fill_todo(&mut self.todo, &self.dir_patterns,
328328
idx + 1, &path, &self.options);
329329
}
330330
}
@@ -502,7 +502,7 @@ impl Pattern {
502502
'[' => {
503503

504504
if i + 4 <= chars.len() && chars[i + 1] == '!' {
505-
match chars[i + 3..].position_elem(&']') {
505+
match chars[i + 3..].iter().position(|x| *x == ']') {
506506
None => (),
507507
Some(j) => {
508508
let chars = &chars[i + 2 .. i + 3 + j];
@@ -513,7 +513,7 @@ impl Pattern {
513513
}
514514
}
515515
} else if i + 3 <= chars.len() && chars[i + 1] != '!' {
516-
match chars[i + 2..].position_elem(&']') {
516+
match chars[i + 2..].iter().position(|x| *x == ']') {
517517
None => (),
518518
Some(j) => {
519519
let cs = parse_char_specifiers(&chars[i + 1 ..
@@ -609,9 +609,7 @@ impl Pattern {
609609
}
610610

611611
/// Access the original glob pattern.
612-
pub fn as_str<'a>(&'a self) -> &'a str {
613-
self.original.as_slice()
614-
}
612+
pub fn as_str<'a>(&'a self) -> &'a str { &self.original }
615613

616614
fn matches_from(&self,
617615
prev_char: Option<char>,
@@ -637,10 +635,9 @@ impl Pattern {
637635
m => return m,
638636
}
639637

640-
let (c, next) = match file.slice_shift_char() {
641-
None => return EntirePatternDoesntMatch,
642-
Some(pair) => pair
643-
};
638+
if file.len() == 0 { return EntirePatternDoesntMatch }
639+
let c = file.chars().next().unwrap();
640+
let next = &file[c.len_utf8()..];
644641

645642
if let AnySequence = *token {
646643
if require_literal(c) {
@@ -653,24 +650,23 @@ impl Pattern {
653650
}
654651
}
655652
_ => {
656-
let (c, next) = match file.slice_shift_char() {
657-
None => return EntirePatternDoesntMatch,
658-
Some(pair) => pair
659-
};
653+
if file.len() == 0 { return EntirePatternDoesntMatch }
654+
let c = file.chars().next().unwrap();
655+
let next = &file[c.len_utf8()..];
660656

661657
let matches = match *token {
662658
AnyChar => {
663659
!require_literal(c)
664660
}
665661
AnyWithin(ref specifiers) => {
666662
!require_literal(c) &&
667-
in_char_specifiers(specifiers.as_slice(),
663+
in_char_specifiers(&specifiers,
668664
c,
669665
options)
670666
}
671667
AnyExcept(ref specifiers) => {
672668
!require_literal(c) &&
673-
!in_char_specifiers(specifiers.as_slice(),
669+
!in_char_specifiers(&specifiers,
674670
c,
675671
options)
676672
}
@@ -740,7 +736,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
740736
// continue. So instead of passing control back to the iterator,
741737
// we can just check for that one entry and potentially recurse
742738
// right away.
743-
let special = "." == s.as_slice() || ".." == s.as_slice();
739+
let special = "." == s || ".." == s;
744740
let next_path = if curdir {PathBuf::new(&s)} else {path.join(&s)};
745741
if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) {
746742
add(todo, next_path);
@@ -819,8 +815,8 @@ fn in_char_specifiers(specifiers: &[CharSpecifier], c: char, options: &MatchOpti
819815
let start = start.to_ascii_lowercase();
820816
let end = end.to_ascii_lowercase();
821817

822-
let start_up = start.to_uppercase();
823-
let end_up = end.to_uppercase();
818+
let start_up = start.to_uppercase().next().unwrap();
819+
let end_up = end.to_uppercase().next().unwrap();
824820

825821
// only allow case insensitive matching when
826822
// both start and end are within a-z or A-Z
@@ -1036,25 +1032,25 @@ mod test {
10361032

10371033
let pat = Pattern::new("a[0-9]b").unwrap();
10381034
for i in 0..10 {
1039-
assert!(pat.matches(format!("a{}b", i).as_slice()));
1035+
assert!(pat.matches(&format!("a{}b", i)));
10401036
}
10411037
assert!(!pat.matches("a_b"));
10421038

10431039
let pat = Pattern::new("a[!0-9]b").unwrap();
10441040
for i in 0..10 {
1045-
assert!(!pat.matches(format!("a{}b", i).as_slice()));
1041+
assert!(!pat.matches(&format!("a{}b", i)));
10461042
}
10471043
assert!(pat.matches("a_b"));
10481044

10491045
let pats = ["[a-z123]", "[1a-z23]", "[123a-z]"];
10501046
for &p in pats.iter() {
10511047
let pat = Pattern::new(p).unwrap();
10521048
for c in "abcdefghijklmnopqrstuvwxyz".chars() {
1053-
assert!(pat.matches(c.to_string().as_slice()));
1049+
assert!(pat.matches(&c.to_string()));
10541050
}
10551051
for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() {
10561052
let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()};
1057-
assert!(pat.matches_with(c.to_string().as_slice(), &options));
1053+
assert!(pat.matches_with(&c.to_string(), &options));
10581054
}
10591055
assert!(pat.matches("1"));
10601056
assert!(pat.matches("2"));
@@ -1101,7 +1097,7 @@ mod test {
11011097
fn test_pattern_escape() {
11021098
let s = "_[_]_?_*_!_";
11031099
assert_eq!(Pattern::escape(s), "_[[]_[]]_[?]_[*]_!_".to_string());
1104-
assert!(Pattern::new(Pattern::escape(s).as_slice()).unwrap().matches(s));
1100+
assert!(Pattern::new(&Pattern::escape(s)).unwrap().matches(s));
11051101
}
11061102

11071103
#[test]

0 commit comments

Comments
 (0)