How to resolve the algorithm Walk a directory/Recursively step by step in the Rust programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Walk a directory/Recursively step by step in the Rust programming language
Table of Contents
Problem Statement
Walk a given directory tree and print files matching a given pattern.
Note: This task is for recursive methods. These tasks should read an entire directory tree, not a single directory.
Note: Please be careful when running any code examples found here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Walk a directory/Recursively step by step in the Rust programming language
Source code in the rust programming language
#![feature(fs_walk)]
use std::fs;
use std::path::Path;
fn main() {
for f in fs::walk_dir(&Path::new("/home/pavel/Music")).unwrap() {
let p = f.unwrap().path();
if p.extension().unwrap_or("".as_ref()) == "mp3" {
println!("{:?}", p);
}
}
}
You may also check:How to resolve the algorithm Idiomatically determine all the characters that can be used for symbols step by step in the Quackery programming language
You may also check:How to resolve the algorithm String concatenation step by step in the Vala programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Pebble programming language
You may also check:How to resolve the algorithm O'Halloran numbers step by step in the BASIC programming language
You may also check:How to resolve the algorithm Word wheel step by step in the JavaScript programming language