pub fn glob(pattern: &str) -> GlobIterator
Return an iterator that produces all the Paths that match the given pattern, which may be absolute or relative to the current working directory.
This method uses the default match options and is equivalent to calling
glob_with(pattern, MatchOptions::new())
. Use glob_with
directly if you
want to use non-default match options.
Consider a directory /media/pictures
containing only the files kittens.jpg
,
puppies.jpg
and hamsters.gif
:
for path in glob("/media/pictures/*.jpg") {
println(path.to_str());
}
The above code will print:
/media/pictures/kittens.jpg
/media/pictures/puppies.jpg
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).