Macro trident_client::construct_path

source ·
macro_rules! construct_path {
    ($root:expr, $($component:expr),*) => { ... };
}
Expand description

Constructs a PathBuf from a given root and a series of path components.

This macro simplifies the creation of a PathBuf from multiple strings or string slices, starting with a root path and appending each subsequent component in order. It’s useful for dynamically constructing file or directory paths in a more readable manner.

§Syntax

construct_path!(root, component1, component2, ..., componentN)

  • root: The base path from which to start. Can be a PathBuf or any type that implements Into<PathBuf>, such as a string or string slice.
  • component1 to componentN: These are the components to be joined to the root path. Each can be any type that implements Into<PathBuf>, allowing for flexible path construction.

§Returns

  • Returns a PathBuf representing the combined path.

§Examples

Basic usage:

use std::path::PathBuf;

// Constructs a PathBuf from a series of string slices
let path = construct_path!(PathBuf::from("/tmp"), "my_project", "src", "main.rs");
assert_eq!(path, PathBuf::from("/tmp/my_project/src/main.rs"));

Note: Replace your_crate_name with the name of your crate where this macro is defined.