@@ -53,8 +53,10 @@ pub struct GlobIterator {
5353/// `puppies.jpg` and `hamsters.gif`:
5454///
5555/// ```rust
56+ /// use extra::glob::glob;
57+ ///
5658/// for path in glob("/media/pictures/*.jpg") {
57- /// println( path.to_str ());
59+ /// println!("{}", path.display ());
5860/// }
5961/// ```
6062///
@@ -188,21 +190,23 @@ enum MatchResult {
188190impl Pattern {
189191
190192 /**
191- * This function compiles Unix shell style patterns: `?` matches any single character,
192- * `*` matches any (possibly empty) sequence of characters and `[...]` matches any character
193- * inside the brackets, unless the first character is `!` in which case it matches any
194- * character except those between the `!` and the `]`. Character sequences can also specify
195- * ranges of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any character
196- * between 0 and 9 inclusive.
193+ * This function compiles Unix shell style patterns: `?` matches any single
194+ * character, `*` matches any (possibly empty) sequence of characters and
195+ * `[...]` matches any character inside the brackets, unless the first
196+ * character is `!` in which case it matches any character except those
197+ * between the `!` and the `]`. Character sequences can also specify ranges
198+ * of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any
199+ * character between 0 and 9 inclusive.
197200 *
198- * The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets (e.g. `[?]`).
199- * When a `]` occurs immediately following `[` or `[!` then it is interpreted as
200- * being part of, rather then ending, the character set, so `]` and NOT `]` can be
201- * matched by `[]]` and `[!]]` respectively. The `-` character can be specified inside a
202- * character sequence pattern by placing it at the start or the end, e.g. `[abc-]`.
201+ * The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets
202+ * (e.g. `[?]`). When a `]` occurs immediately following `[` or `[!` then
203+ * it is interpreted as being part of, rather then ending, the character
204+ * set, so `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively.
205+ * The `-` character can be specified inside a character sequence pattern by
206+ * placing it at the start or the end, e.g. `[abc-]`.
203207 *
204- * When a `[` does not have a closing `]` before the end of the string then the `[` will
205- * be treated literally.
208+ * When a `[` does not have a closing `]` before the end of the string then
209+ * the `[` will be treated literally.
206210 */
207211 pub fn new ( pattern : & str ) -> Pattern {
208212
@@ -229,7 +233,8 @@ impl Pattern {
229233 match chars. slice_from ( i + 3 ) . position_elem ( & ']' ) {
230234 None => ( ) ,
231235 Some ( j) => {
232- let cs = parse_char_specifiers ( chars. slice ( i + 2 , i + 3 + j) ) ;
236+ let chars = chars. slice ( i + 2 , i + 3 + j) ;
237+ let cs = parse_char_specifiers ( chars) ;
233238 tokens. push ( AnyExcept ( cs) ) ;
234239 i += j + 4 ;
235240 continue ;
@@ -292,6 +297,8 @@ impl Pattern {
292297 * # Example
293298 *
294299 * ```rust
300+ * use extra::glob::Pattern;
301+ *
295302 * assert!(Pattern::new("c?t").matches("cat"));
296303 * assert!(Pattern::new("k[!e]tteh").matches("kitteh"));
297304 * assert!(Pattern::new("d*g").matches("doog"));
@@ -509,7 +516,7 @@ impl MatchOptions {
509516 *
510517 * This function always returns this value:
511518 *
512- * ```rust
519+ * ```rust,notest
513520 * MatchOptions {
514521 * case_sensitive: true,
515522 * require_literal_separator: false.
0 commit comments