Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ after the declaration using the `=>` operator:
use path_no_alloc::with_paths;

let p1 = "some/dir";
let p2 = "file.txt";

let file_exists: bool = with_paths! {
path = p1 / p2 => path.exists()
path = p1 / "file.txt" => path.exists()
};
```

Expand All @@ -51,13 +50,12 @@ use std::path::{Path, PathBuf};

let p1 = Path::new("hello");
let p2 = "world".to_string();
let my_file = "file.txt";
let some_root = PathBuf::from("some/project/root");

let path_exists = with_paths! {
path = p1 / p2,
another_path = some_root / p1 / my_file,
some_third_path = p1 / p2 / some_root / my_file
another_path = some_root / p1 / "file.txt",
some_third_path = p1 / p2 / some_root / "file.txt"

=>

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn join_in_buff<'a, const N: usize>(
macro_rules! with_paths {
// Declaration mode
{
$( $name:ident = $( $path:ident ) / + ),*
$( $name:ident = $( $path:tt ) / + ),* $(,)?
} => {
$(
let mut __with_paths_arr: [std::mem::MaybeUninit<u8>; 128] = unsafe { std::mem::MaybeUninit::uninit().assume_init() };
Expand All @@ -135,7 +135,7 @@ macro_rules! with_paths {

// Expression mode
{
$( $name:ident = $( $path:ident ) / + ),*
$( $name:ident = $( $path:tt ) / + ),* $(,)?
=> $( $statements:stmt );* $(;)?
} => {
{
Expand Down