Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macro_rules! path {
- (!$($rest:tt)*) => {{
- ::std::path::PathBuf::from(
- ::std::path::MAIN_SEPARATOR.to_string()
- ).join(path!($($rest)*))
- }};
- ($part:ident) => {{
- ::std::path::PathBuf::from(stringify!($part))
- }};
- ($part:ident / $($rest:tt)*) => {{
- path!($part).join(path!($($rest)*))
- }};
- }
- fn main() {
- println!("{:?}", path!(foo/bar/baz));
- println!("{:?}", path!(!usr/bin/sh)); // absolute
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement