Skip to content

Commit bbcfbab

Browse files
committed
Bump to 0.2.7
1 parent aa2978f commit bbcfbab

File tree

3 files changed

+120
-116
lines changed

3 files changed

+120
-116
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.6"
4+
version = "0.2.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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2424
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2525
html_root_url = "http://doc.rust-lang.org/glob/")]
26+
#![feature(convert)]
2627
#![cfg_attr(all(test, windows), feature(std_misc))]
2728

2829
use std::ascii::AsciiExt;
@@ -180,7 +181,7 @@ pub fn glob_with(pattern: &str, options: &MatchOptions)
180181
});
181182
}
182183

183-
let scope = root.map(to_scope).unwrap_or_else(|| PathBuf::new("."));
184+
let scope = root.map(to_scope).unwrap_or_else(|| PathBuf::from("."));
184185

185186
let mut dir_patterns = Vec::new();
186187
let components = pattern[cmp::min(root_len, pattern.len())..]
@@ -746,7 +747,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
746747
// we can just check for that one entry and potentially recurse
747748
// right away.
748749
let special = "." == s || ".." == s;
749-
let next_path = if curdir {PathBuf::new(&s)} else {path.join(&s)};
750+
let next_path = if curdir {PathBuf::from(s)} else {path.join(&s)};
750751
if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) {
751752
add(todo, next_path);
752753
}
@@ -755,7 +756,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
755756
let dirs = fs::read_dir(path).and_then(|d| {
756757
d.map(|e| e.map(|e| {
757758
if curdir {
758-
PathBuf::new(e.path().file_name().unwrap())
759+
PathBuf::from(e.path().file_name().unwrap())
759760
} else {
760761
e.path()
761762
}

tests/glob-std.rs

Lines changed: 115 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
// ignore-windows TempDir may cause IoError on windows: #10462
1212

13+
#![feature(convert)]
14+
#![cfg_attr(test, deny(warnings)]
15+
1316
extern crate glob;
1417
extern crate tempdir;
1518

@@ -78,199 +81,199 @@ fn main() {
7881

7982
// all recursive entities
8083
assert_eq!(glob_vec("r/**"), vec!(
81-
PathBuf::new("r/another"),
82-
PathBuf::new("r/one"),
83-
PathBuf::new("r/one/another"),
84-
PathBuf::new("r/one/another/deep"),
85-
PathBuf::new("r/three"),
86-
PathBuf::new("r/two")));
84+
PathBuf::from("r/another"),
85+
PathBuf::from("r/one"),
86+
PathBuf::from("r/one/another"),
87+
PathBuf::from("r/one/another/deep"),
88+
PathBuf::from("r/three"),
89+
PathBuf::from("r/two")));
8790

8891
// collapse consecutive recursive patterns
8992
assert_eq!(glob_vec("r/**/**"), vec!(
90-
PathBuf::new("r/another"),
91-
PathBuf::new("r/one"),
92-
PathBuf::new("r/one/another"),
93-
PathBuf::new("r/one/another/deep"),
94-
PathBuf::new("r/three"),
95-
PathBuf::new("r/two")));
93+
PathBuf::from("r/another"),
94+
PathBuf::from("r/one"),
95+
PathBuf::from("r/one/another"),
96+
PathBuf::from("r/one/another/deep"),
97+
PathBuf::from("r/three"),
98+
PathBuf::from("r/two")));
9699

97100
assert_eq!(glob_vec("r/**/*"), vec!(
98-
PathBuf::new("r/another"),
99-
PathBuf::new("r/another/a.md"),
100-
PathBuf::new("r/current_dir.md"),
101-
PathBuf::new("r/one"),
102-
PathBuf::new("r/one/a.md"),
103-
PathBuf::new("r/one/another"),
104-
PathBuf::new("r/one/another/a.md"),
105-
PathBuf::new("r/one/another/deep"),
106-
PathBuf::new("r/one/another/deep/spelunking.md"),
107-
PathBuf::new("r/three"),
108-
PathBuf::new("r/three/c.md"),
109-
PathBuf::new("r/two"),
110-
PathBuf::new("r/two/b.md")));
101+
PathBuf::from("r/another"),
102+
PathBuf::from("r/another/a.md"),
103+
PathBuf::from("r/current_dir.md"),
104+
PathBuf::from("r/one"),
105+
PathBuf::from("r/one/a.md"),
106+
PathBuf::from("r/one/another"),
107+
PathBuf::from("r/one/another/a.md"),
108+
PathBuf::from("r/one/another/deep"),
109+
PathBuf::from("r/one/another/deep/spelunking.md"),
110+
PathBuf::from("r/three"),
111+
PathBuf::from("r/three/c.md"),
112+
PathBuf::from("r/two"),
113+
PathBuf::from("r/two/b.md")));
111114

112115
// followed by a wildcard
113116
assert_eq!(glob_vec("r/**/*.md"), vec!(
114-
PathBuf::new("r/another/a.md"),
115-
PathBuf::new("r/current_dir.md"),
116-
PathBuf::new("r/one/a.md"),
117-
PathBuf::new("r/one/another/a.md"),
118-
PathBuf::new("r/one/another/deep/spelunking.md"),
119-
PathBuf::new("r/three/c.md"),
120-
PathBuf::new("r/two/b.md")));
117+
PathBuf::from("r/another/a.md"),
118+
PathBuf::from("r/current_dir.md"),
119+
PathBuf::from("r/one/a.md"),
120+
PathBuf::from("r/one/another/a.md"),
121+
PathBuf::from("r/one/another/deep/spelunking.md"),
122+
PathBuf::from("r/three/c.md"),
123+
PathBuf::from("r/two/b.md")));
121124

122125
// followed by a precise pattern
123126
assert_eq!(glob_vec("r/one/**/a.md"), vec!(
124-
PathBuf::new("r/one/a.md"),
125-
PathBuf::new("r/one/another/a.md")));
127+
PathBuf::from("r/one/a.md"),
128+
PathBuf::from("r/one/another/a.md")));
126129

127130
// followed by another recursive pattern
128131
// collapses consecutive recursives into one
129132
assert_eq!(glob_vec("r/one/**/**/a.md"), vec!(
130-
PathBuf::new("r/one/a.md"),
131-
PathBuf::new("r/one/another/a.md")));
133+
PathBuf::from("r/one/a.md"),
134+
PathBuf::from("r/one/another/a.md")));
132135

133136
// followed by two precise patterns
134137
assert_eq!(glob_vec("r/**/another/a.md"), vec!(
135-
PathBuf::new("r/another/a.md"),
136-
PathBuf::new("r/one/another/a.md")));
138+
PathBuf::from("r/another/a.md"),
139+
PathBuf::from("r/one/another/a.md")));
137140

138141
assert_eq!(glob_vec(""), Vec::new());
139-
assert_eq!(glob_vec("."), vec!(PathBuf::new(".")));
140-
assert_eq!(glob_vec(".."), vec!(PathBuf::new("..")));
142+
assert_eq!(glob_vec("."), vec!(PathBuf::from(".")));
143+
assert_eq!(glob_vec(".."), vec!(PathBuf::from("..")));
141144

142-
assert_eq!(glob_vec("aaa"), vec!(PathBuf::new("aaa")));
143-
assert_eq!(glob_vec("aaa/"), vec!(PathBuf::new("aaa")));
145+
assert_eq!(glob_vec("aaa"), vec!(PathBuf::from("aaa")));
146+
assert_eq!(glob_vec("aaa/"), vec!(PathBuf::from("aaa")));
144147
assert_eq!(glob_vec("a"), Vec::new());
145148
assert_eq!(glob_vec("aa"), Vec::new());
146149
assert_eq!(glob_vec("aaaa"), Vec::new());
147150

148-
assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::new("aaa/apple")));
151+
assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::from("aaa/apple")));
149152
assert_eq!(glob_vec("aaa/apple/nope"), Vec::new());
150153

151154
// windows should support both / and \ as directory separators
152155
if env::consts::FAMILY == "windows" {
153-
assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::new("aaa/apple")));
156+
assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::from("aaa/apple")));
154157
}
155158

156159
assert_eq!(glob_vec("???/"), vec!(
157-
PathBuf::new("aaa"),
158-
PathBuf::new("bbb"),
159-
PathBuf::new("ccc"),
160-
PathBuf::new("xyz")));
160+
PathBuf::from("aaa"),
161+
PathBuf::from("bbb"),
162+
PathBuf::from("ccc"),
163+
PathBuf::from("xyz")));
161164

162165
assert_eq!(glob_vec("aaa/tomato/tom?to.txt"), vec!(
163-
PathBuf::new("aaa/tomato/tomato.txt"),
164-
PathBuf::new("aaa/tomato/tomoto.txt")));
166+
PathBuf::from("aaa/tomato/tomato.txt"),
167+
PathBuf::from("aaa/tomato/tomoto.txt")));
165168

166169
assert_eq!(glob_vec("xyz/?"), vec!(
167-
PathBuf::new("xyz/x"),
168-
PathBuf::new("xyz/y"),
169-
PathBuf::new("xyz/z")));
170-
171-
assert_eq!(glob_vec("a*"), vec!(PathBuf::new("aaa")));
172-
assert_eq!(glob_vec("*a*"), vec!(PathBuf::new("aaa")));
173-
assert_eq!(glob_vec("a*a"), vec!(PathBuf::new("aaa")));
174-
assert_eq!(glob_vec("aaa*"), vec!(PathBuf::new("aaa")));
175-
assert_eq!(glob_vec("*aaa"), vec!(PathBuf::new("aaa")));
176-
assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::new("aaa")));
177-
assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::new("aaa")));
178-
assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::new("aaa")));
170+
PathBuf::from("xyz/x"),
171+
PathBuf::from("xyz/y"),
172+
PathBuf::from("xyz/z")));
173+
174+
assert_eq!(glob_vec("a*"), vec!(PathBuf::from("aaa")));
175+
assert_eq!(glob_vec("*a*"), vec!(PathBuf::from("aaa")));
176+
assert_eq!(glob_vec("a*a"), vec!(PathBuf::from("aaa")));
177+
assert_eq!(glob_vec("aaa*"), vec!(PathBuf::from("aaa")));
178+
assert_eq!(glob_vec("*aaa"), vec!(PathBuf::from("aaa")));
179+
assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::from("aaa")));
180+
assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::from("aaa")));
181+
assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::from("aaa")));
179182

180183
assert_eq!(glob_vec("aaa/*"), vec!(
181-
PathBuf::new("aaa/apple"),
182-
PathBuf::new("aaa/orange"),
183-
PathBuf::new("aaa/tomato")));
184+
PathBuf::from("aaa/apple"),
185+
PathBuf::from("aaa/orange"),
186+
PathBuf::from("aaa/tomato")));
184187

185188
assert_eq!(glob_vec("aaa/*a*"), vec!(
186-
PathBuf::new("aaa/apple"),
187-
PathBuf::new("aaa/orange"),
188-
PathBuf::new("aaa/tomato")));
189+
PathBuf::from("aaa/apple"),
190+
PathBuf::from("aaa/orange"),
191+
PathBuf::from("aaa/tomato")));
189192

190193
assert_eq!(glob_vec("*/*/*.txt"), vec!(
191-
PathBuf::new("aaa/tomato/tomato.txt"),
192-
PathBuf::new("aaa/tomato/tomoto.txt")));
194+
PathBuf::from("aaa/tomato/tomato.txt"),
195+
PathBuf::from("aaa/tomato/tomoto.txt")));
193196

194197
assert_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), vec!(
195-
PathBuf::new("aaa/tomato/tomato.txt"),
196-
PathBuf::new("aaa/tomato/tomoto.txt")));
198+
PathBuf::from("aaa/tomato/tomato.txt"),
199+
PathBuf::from("aaa/tomato/tomoto.txt")));
197200

198-
assert_eq!(glob_vec("./aaa"), vec!(PathBuf::new("aaa")));
201+
assert_eq!(glob_vec("./aaa"), vec!(PathBuf::from("aaa")));
199202
assert_eq!(glob_vec("./*"), glob_vec("*"));
200-
assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::new("xyz/.."));
201-
assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::new("aaa/../bbb")));
203+
assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::from("xyz/.."));
204+
assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::from("aaa/../bbb")));
202205
assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new());
203206
assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new());
204207

205208
assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new());
206209

207-
assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::new("aaa")));
208-
assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::new("aaa")));
209-
assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::new("aaa")));
210+
assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::from("aaa")));
211+
assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::from("aaa")));
212+
assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::from("aaa")));
210213
assert_eq!(glob_vec("aa[b]"), Vec::new());
211214
assert_eq!(glob_vec("aa[xyz]"), Vec::new());
212215
assert_eq!(glob_vec("aa[]]"), Vec::new());
213216

214-
assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::new("aaa")));
215-
assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::new("aaa")));
216-
assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::new("aaa")));
217+
assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::from("aaa")));
218+
assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::from("aaa")));
219+
assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::from("aaa")));
217220
assert_eq!(glob_vec("aa[!a]"), Vec::new());
218221
assert_eq!(glob_vec("aa[!abc]"), Vec::new());
219222

220-
assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::new("bbb/specials/[")));
221-
assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::new("bbb/specials/!")));
222-
assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::new("bbb/specials/]")));
223+
assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::from("bbb/specials/[")));
224+
assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::from("bbb/specials/!")));
225+
assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::from("bbb/specials/]")));
223226

224227
if env::consts::FAMILY != "windows" {
225-
assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::new("bbb/specials/*")));
226-
assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::new("bbb/specials/?")));
228+
assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::from("bbb/specials/*")));
229+
assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::from("bbb/specials/?")));
227230
}
228231

229232
if env::consts::FAMILY == "windows" {
230233

231234
assert_eq!(glob_vec("bbb/specials/[![]"), vec!(
232-
PathBuf::new("bbb/specials/!"),
233-
PathBuf::new("bbb/specials/]")));
235+
PathBuf::from("bbb/specials/!"),
236+
PathBuf::from("bbb/specials/]")));
234237

235238
assert_eq!(glob_vec("bbb/specials/[!]]"), vec!(
236-
PathBuf::new("bbb/specials/!"),
237-
PathBuf::new("bbb/specials/[")));
239+
PathBuf::from("bbb/specials/!"),
240+
PathBuf::from("bbb/specials/[")));
238241

239242
assert_eq!(glob_vec("bbb/specials/[!!]"), vec!(
240-
PathBuf::new("bbb/specials/["),
241-
PathBuf::new("bbb/specials/]")));
243+
PathBuf::from("bbb/specials/["),
244+
PathBuf::from("bbb/specials/]")));
242245

243246
} else {
244247

245248
assert_eq!(glob_vec("bbb/specials/[![]"), vec!(
246-
PathBuf::new("bbb/specials/!"),
247-
PathBuf::new("bbb/specials/*"),
248-
PathBuf::new("bbb/specials/?"),
249-
PathBuf::new("bbb/specials/]")));
249+
PathBuf::from("bbb/specials/!"),
250+
PathBuf::from("bbb/specials/*"),
251+
PathBuf::from("bbb/specials/?"),
252+
PathBuf::from("bbb/specials/]")));
250253

251254
assert_eq!(glob_vec("bbb/specials/[!]]"), vec!(
252-
PathBuf::new("bbb/specials/!"),
253-
PathBuf::new("bbb/specials/*"),
254-
PathBuf::new("bbb/specials/?"),
255-
PathBuf::new("bbb/specials/[")));
255+
PathBuf::from("bbb/specials/!"),
256+
PathBuf::from("bbb/specials/*"),
257+
PathBuf::from("bbb/specials/?"),
258+
PathBuf::from("bbb/specials/[")));
256259

257260
assert_eq!(glob_vec("bbb/specials/[!!]"), vec!(
258-
PathBuf::new("bbb/specials/*"),
259-
PathBuf::new("bbb/specials/?"),
260-
PathBuf::new("bbb/specials/["),
261-
PathBuf::new("bbb/specials/]")));
261+
PathBuf::from("bbb/specials/*"),
262+
PathBuf::from("bbb/specials/?"),
263+
PathBuf::from("bbb/specials/["),
264+
PathBuf::from("bbb/specials/]")));
262265

263266
assert_eq!(glob_vec("bbb/specials/[!*]"), vec!(
264-
PathBuf::new("bbb/specials/!"),
265-
PathBuf::new("bbb/specials/?"),
266-
PathBuf::new("bbb/specials/["),
267-
PathBuf::new("bbb/specials/]")));
267+
PathBuf::from("bbb/specials/!"),
268+
PathBuf::from("bbb/specials/?"),
269+
PathBuf::from("bbb/specials/["),
270+
PathBuf::from("bbb/specials/]")));
268271

269272
assert_eq!(glob_vec("bbb/specials/[!?]"), vec!(
270-
PathBuf::new("bbb/specials/!"),
271-
PathBuf::new("bbb/specials/*"),
272-
PathBuf::new("bbb/specials/["),
273-
PathBuf::new("bbb/specials/]")));
273+
PathBuf::from("bbb/specials/!"),
274+
PathBuf::from("bbb/specials/*"),
275+
PathBuf::from("bbb/specials/["),
276+
PathBuf::from("bbb/specials/]")));
274277

275278
}
276279
}

0 commit comments

Comments
 (0)