Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Last active June 26, 2017 15:00
Show Gist options
  • Select an option

  • Save fivetanley/d36cd0627105a393d4a7869c708f7fd0 to your computer and use it in GitHub Desktop.

Select an option

Save fivetanley/d36cd0627105a393d4a7869c708f7fd0 to your computer and use it in GitHub Desktop.
extern crate glob;
use glob::glob;
use std::fs;
use std::path;
// trying to print out only directories
fn main() {
// the .unwrap here should convert a Result<PathBuf, GlobError> to
// just the PathBuf, which you should be able to call .is_dir() on?
let files = glob("/Users/sstuart/src/dashboard4/app/**/*")
.expect("Failed to read glob pattern")
.filter( |x| x.clone().unwrap().is_dir());
for entry in files {
println!("{:?}", entry);
}
}
@fivetanley
Copy link
Copy Markdown
Author

compiler output:

➜  stale-file-cleaner git:(master) ✗ cargo run
   Compiling stale-file-cleaner v0.1.0 (file:///Users/sstuart/src/stale-file-cleaner)
error[E0507]: cannot move out of borrowed content
  --> src/main.rs:10:22
   |
10 |         .filter( |x| x.clone().unwrap().is_dir());
   |                      ^^^^^^^^^ cannot move out of borrowed content

error: aborting due to previous error

error: Could not compile `stale-file-cleaner`.

To learn more, run the command again with --verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment