Skip to content

Commit 7b93aae

Browse files
committed
Touch up some line limits
1 parent 7714144 commit 7b93aae

File tree

1 file changed

+40
-29
lines changed

1 file changed

+40
-29
lines changed

src/lib.rs

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
//! Support for matching file paths against Unix shell style patterns.
1212
//!
13-
//! The `glob` and `glob_with` functions allow querying the filesystem for all files
14-
//! that match a particular pattern (similar to the libc `glob` function). The methods on the
15-
//! `Pattern` type provide functionality for checking if individual paths match a
16-
//! particular pattern (similar to the libc `fnmatch` function).
13+
//! The `glob` and `glob_with` functions allow querying the filesystem for all
14+
//! files that match a particular pattern (similar to the libc `glob` function).
15+
//! The methods on the `Pattern` type provide functionality for checking if
16+
//! individual paths match a particular pattern (similar to the libc `fnmatch`
17+
//! function).
1718
//!
1819
//! For consistency across platforms, and for Windows support, this module
1920
//! is implemented entirely in Rust rather than deferring to the libc
@@ -34,8 +35,9 @@
3435
//! }
3536
//! ```
3637
//!
37-
//! To print all files containing the letter "a", case insensitive, in a `local` directory
38-
//! relative to the current working directory. This ignores errors instead of printing them.
38+
//! To print all files containing the letter "a", case insensitive, in a `local`
39+
//! directory relative to the current working directory. This ignores errors
40+
//! instead of printing them.
3941
//!
4042
//! ```rust,no_run
4143
//! use glob::glob_with;
@@ -46,7 +48,7 @@
4648
//! require_literal_separator: false,
4749
//! require_literal_leading_dot: false,
4850
//! };
49-
//! for entry in glob_with("local/*a*", &options).expect("Failed to read glob pattern") {
51+
//! for entry in glob_with("local/*a*", &options).unwrap() {
5052
//! if let Ok(path) = entry {
5153
//! println!("{:?}", path.display())
5254
//! }
@@ -90,8 +92,9 @@ pub struct Paths {
9092
scope: Option<PathBuf>,
9193
}
9294

93-
/// Return an iterator that produces all the `Path`s that match the given pattern using default
94-
/// match options, which may be absolute or relative to the current working directory.
95+
/// Return an iterator that produces all the `Path`s that match the given
96+
/// pattern using default match options, which may be absolute or relative to
97+
/// the current working directory.
9598
///
9699
/// This may return an error if the pattern is invalid.
97100
///
@@ -150,8 +153,9 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
150153
glob_with(pattern, &MatchOptions::new())
151154
}
152155

153-
/// Return an iterator that produces all the `Path`s that match the given pattern using the
154-
/// specified match options, which may be absolute or relative to the current working directory.
156+
/// Return an iterator that produces all the `Path`s that match the given
157+
/// pattern using the specified match options, which may be absolute or relative
158+
/// to the current working directory.
155159
///
156160
/// This may return an error if the pattern is invalid.
157161
///
@@ -162,7 +166,8 @@ pub fn glob(pattern: &str) -> Result<Paths, PatternError> {
162166
/// passed to this function.
163167
///
164168
/// Paths are yielded in alphabetical order.
165-
pub fn glob_with(pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError> {
169+
pub fn glob_with(pattern: &str, options: &MatchOptions)
170+
-> Result<Paths, PatternError> {
166171
// make sure that the pattern is valid first, else early return with error
167172
let _compiled = try!(Pattern::new(pattern));
168173

@@ -240,7 +245,8 @@ pub fn glob_with(pattern: &str, options: &MatchOptions) -> Result<Paths, Pattern
240245
});
241246
}
242247

243-
let require_dir = pattern.chars().next_back().map(path::is_separator) == Some(true);
248+
let last_is_separator = pattern.chars().next_back().map(path::is_separator);
249+
let require_dir = last_is_separator == Some(true);
244250
let todo = Vec::new();
245251

246252
Ok(Paths {
@@ -316,7 +322,11 @@ impl Iterator for Paths {
316322
// Shouldn't happen, but we're using -1 as a special index.
317323
assert!(self.dir_patterns.len() < !0 as usize);
318324

319-
fill_todo(&mut self.todo, &self.dir_patterns, 0, &scope, &self.options);
325+
fill_todo(&mut self.todo,
326+
&self.dir_patterns,
327+
0,
328+
&scope,
329+
&self.options);
320330
}
321331
}
322332

@@ -370,7 +380,8 @@ impl Iterator for Paths {
370380
// advanced to the next pattern for this path
371381
idx = next + 1;
372382
} else {
373-
// not a directory and it's the last pattern, meaning no match
383+
// not a directory and it's the last pattern, meaning no
384+
// match
374385
continue;
375386
}
376387
}
@@ -435,24 +446,24 @@ impl fmt::Display for PatternError {
435446
/// - `*` matches any (possibly empty) sequence of characters.
436447
///
437448
/// - `**` matches the current directory and arbitrary subdirectories. This
438-
/// sequence **must** form a single path component, so both `**a` and `b**` are
439-
/// invalid and will result in an error. A sequence of more than two
440-
/// consecutive `*` characters is also invalid.
449+
/// sequence **must** form a single path component, so both `**a` and `b**`
450+
/// are invalid and will result in an error. A sequence of more than two
451+
/// consecutive `*` characters is also invalid.
441452
///
442-
/// - `[...]` matches any character inside the brackets.
443-
/// Character sequences can also specify ranges
444-
/// of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any
445-
/// character between 0 and 9 inclusive. An unclosed bracket is invalid.
453+
/// - `[...]` matches any character inside the brackets. Character sequences
454+
/// can also specify ranges of characters, as ordered by Unicode, so e.g.
455+
/// `[0-9]` specifies any character between 0 and 9 inclusive. An unclosed
456+
/// bracket is invalid.
446457
///
447-
/// - `[!...]` is the negation of `[...]`, i.e. it matches any characters **not**
448-
/// in the brackets.
458+
/// - `[!...]` is the negation of `[...]`, i.e. it matches any characters
459+
/// **not** in the brackets.
449460
///
450461
/// - The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets
451-
/// (e.g. `[?]`). When a `]` occurs immediately following `[` or `[!` then
452-
/// it is interpreted as being part of, rather then ending, the character
453-
/// set, so `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively.
454-
/// The `-` character can be specified inside a character sequence pattern by
455-
/// placing it at the start or the end, e.g. `[abc-]`.
462+
/// (e.g. `[?]`). When a `]` occurs immediately following `[` or `[!` then it
463+
/// is interpreted as being part of, rather then ending, the character set, so
464+
/// `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively. The `-`
465+
/// character can be specified inside a character sequence pattern by placing
466+
/// it at the start or the end, e.g. `[abc-]`.
456467
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
457468
pub struct Pattern {
458469
original: String,

0 commit comments

Comments
 (0)