Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitt3120/get_files_macro
A Rust macro that can resolve a directory's file names before compile-time.
https://github.com/kitt3120/get_files_macro
enumeration file files macro macros rust
Last synced: 9 days ago
JSON representation
A Rust macro that can resolve a directory's file names before compile-time.
- Host: GitHub
- URL: https://github.com/kitt3120/get_files_macro
- Owner: Kitt3120
- License: mit
- Created: 2023-12-28T14:06:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2023-12-28T16:54:01.000Z (10 months ago)
- Last Synced: 2024-10-06T15:15:54.500Z (about 1 month ago)
- Topics: enumeration, file, files, macro, macros, rust
- Language: Rust
- Homepage: https://crates.io/crates/get_files_macro
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get_files_macro
A Rust macro that can resolve a directory's file names before compile-time.
# Usage
```rust
// This scenario is meant to be executed from this repo's rootlet 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](https://github.com/Kitt3120/get_files_macro/actions/workflows/deploy.yml/badge.svg)](https://github.com/Kitt3120/get_files_macro/actions/workflows/deploy.yml)
# 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.