Skip to content

A Rust macro that can resolve a directory's file names before compile-time.

License

Notifications You must be signed in to change notification settings

Kitt3120/get_files_macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get_files_macro

A Rust macro that can resolve a directory's file names before compile-time.

Usage

// This scenario is meant to be executed from this repo's root

let file_names = get_files!(true, true, true, true, true, "/", "./test");
// ^^^^^^^^^^^ -> Vec<&str>

let test_names = vec![
    "testfile1.test",
    "testfile2.test",
    "zzz",
    "zzz/testfile3.test",
    ".testfile.test",
    "testfile.link",
];

assert_eq!(file_names.len(), test_names.len());
for (index, file_name) in file_names.into_iter().enumerate() {
    assert_eq!(file_name, test_names[index]);
}

println!("All tests passed!");

Status

Deployment status: Deploy

Why?

I wanted to extend sqlx with a function that can check if a database's migrations are up-to-date. To do that, I needed to get the names of all files in a directory before compile-time. I couldn't find a way to do that, so I made this macro.

About

A Rust macro that can resolve a directory's file names before compile-time.

Topics

Resources

License

Stars

Watchers

Forks

Languages