The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Find A File In A Directory Tree By Name In Rust

TODO: Pull subtitle into page object
Code
use std::path::PathBuf;
use walkdir::WalkDir;

fn main() {
    let file_path = get_path_to_file("the-target");
    dbg!(&file_path);
}

fn get_path_to_file(target_name: &str) -> PathBuf {
    let asdf: Vec<_> = WalkDir::new(".")
        .into_iter()
        .filter_map(|v| {
            if let Some(name) = v.as_ref().unwrap().path().file_stem() {
                if name == target_name {
                    Some(v.as_ref().unwrap().path().display().to_string())
                } else {
                    None
                }
            } else {
                None
            }
        })
        .collect();
    PathBuf::from(&asdf[0])
}



Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Find A File In A Directory Tree By Name In Rust

TODO: Fill this out

-- code
-- rust

use std::path::PathBuf;
use walkdir::WalkDir;

fn main() {
    let file_path = get_path_to_file("the-target");
    dbg!(&file_path);
}

fn get_path_to_file(target_name: &str) -> PathBuf {
    let asdf: Vec<_> = WalkDir::new(".")
        .into_iter()
        .filter_map(|v| {
            if let Some(name) = v.as_ref().unwrap().path().file_stem() {
                if name == target_name {
                    Some(v.as_ref().unwrap().path().display().to_string())
                } else {
                    None
                }
            } else {
                None
            }
        })
        .collect();
    PathBuf::from(&asdf[0])
}





-- categories
-- Rust 

-- metadata
-- date: 2023-07-12 01:03:51
-- id: 2ssrwcrt
-- site: aws
-- type: post
-- status: draft