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.

Get A Recursive List Of File In A Directory With A Given Extension In Rust

TODO: Pull subtitle into page object
Code
//! ```cargo
//! [package]
//! edition = "2021"
//! [dependencies]
//! walkdir = "2"
//! ```

#![allow(warnings)]
use walkdir::{DirEntry, WalkDir};
use std::path::PathBuf;

fn main() {
  let files = dir_list("recursive_test", "html");
  dbg!(files);
}

fn dir_list(dir: &str, extension: &str) -> Vec<PathBuf>{
  WalkDir::new(dir)
    .into_iter()
    .filter(|e| {
    match e.as_ref().unwrap().path().extension() {
      Some(ext) => ext.to_str().unwrap() == extension,
      None => false 
    }})
    .map(|e| e.as_ref().unwrap().path().to_path_buf())
    .collect()
}
Results
[_active_nvim_run:15] files = [
    "recursive_test/example/a/c/delta.html",
    "recursive_test/example/alfa.html",
    "recursive_test/example/bravo.html",
    "recursive_test/example/b/charlie.html",
]

Debugging Stuff

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

        -- title

Get A Recursive List Of File In A 
Directory With A Given Extension In Rust

-- code
-- rust


//! ```cargo
//! [package]
//! edition = "2021"
//! [dependencies]
//! walkdir = "2"
//! ```

#![allow(warnings)]
use walkdir::{DirEntry, WalkDir};
use std::path::PathBuf;

fn main() {
  let files = dir_list("recursive_test", "html");
  dbg!(files);
}

fn dir_list(dir: &str, extension: &str) -> Vec<PathBuf>{
  WalkDir::new(dir)
    .into_iter()
    .filter(|e| {
    match e.as_ref().unwrap().path().extension() {
      Some(ext) => ext.to_str().unwrap() == extension,
      None => false 
    }})
    .map(|e| e.as_ref().unwrap().path().to_path_buf())
    .collect()
}

-- results/

[_active_nvim_run:15] files = [
    "recursive_test/example/a/c/delta.html",
    "recursive_test/example/alfa.html",
    "recursive_test/example/bravo.html",
    "recursive_test/example/b/charlie.html",
]

-- /results


-- results/

-- /results


-- categories
-- Rust 

-- groups

-- metadata
-- date: 2024-01-03 23:45:28
-- id: 2atxqmma
-- site: aws
-- type: post
-- status: draft