A convenient macro for building PathBufs in Rust.

Overview

pathbuf

pathbuf is a simple crate which provides the pathbuf macro to conveniently construct the Rust PathBuf type.

Example

use pathbuf::pathbuf;
use std::path::PathBuf;

fn main() {
	let p = pathbuf!["hello", "filename.txt"];

	let expected = {
		let mut temp = PathBuf::new();
		temp.push("hello");
		temp.push("filename.txt");
		temp
	};

	assert_eq!(p, expected);
}

License

pathbuf is licensed under the Apache 2.0 license, and is itself a reproduction of the hc_pathbuf crate found in Hipcheck, pulled out into its own distinct crate for reuse.

You might also like...
Quick'n dirty macro set for advent of code 2021

AOC quick'n dirty macro set Those are implemented using quick'n dirty procedural macros and libraries. Running the program Use cargo run --release --

Semantic find-and-replace using tree-sitter-based macro expansion

Semantic find-and-replace using tree-sitter-based macro expansion

An html macro for dioxus applications.

dioxus html macro This crate offers an html! like macro for dioxus applications. It expands to the equivalent rsx! macro call you would have made othe

An attribute macro to simplify writing simple command line applications.

fncli An attribute macro to simplify writing simple command line applications. Example #[fncli::cli] fn main(a: i32, b: i32) { println!("{}", a +

Macro to customize the behavior of `?`

::custom-try Macro to customize the behavior of ? Examples use ::custom_try::custom_try; #[repr(transparent)] pub struct FfiResult { pub status_c

A micro crate that simplifies a bit the use of the std macro thread_local!.

with-thread-local A micro crate that simplifies a bit the use of the std macro thread_local!. extern crate regex; use with_thread_local::with_thread_

A formatter for the leptos view! macro

leptosfmt A formatter for the leptos view! macro All notable changes are documented in: CHANGELOG.md Install cargo install leptosfmt or for trying out

Flexible deriving macro.

This library is a slightly more convenient version of derive for newtype pattern. = See also Deriving via Basic Usage #[derive(DerivingVia)] and then

A HTML to node macro powered by rstml.

html-node A HTML to node macro powered by rstml. Features Text escaping Pretty-printing NEW: type-safe elements and attributes! (example) Example let

Comments
  • [enhancement] add note regarding path traversal attack

    [enhancement] add note regarding path traversal attack

    This isn't a particular problem of this crate, rather a missing push_one in the standard library, as push allows multiple components. But it would be good to document it also in this crate, so people don't forget about it.

    If you want to add a path traversal protected version, have a look at a implementation by me. Otherwise I will create a crate with this functionality (w\o macro), when I have time, but it could fit to this crate.

    opened by TheAlgorythm 0
Owner
Andrew Lilley Brinker
Software supply chain security and Rust.
Andrew Lilley Brinker
Simple but convenient CLI-based Matrix client app for sending and receiving (in Rust)

matrix-commander-rs simple but convenient CLI-based Matrix client app for sending and receiving Help create this Rust program! This project is current

null 19 Dec 30, 2022
Irx-config - The library provides convenient way to represent/parse configuration from different sources

The irx-config library provides convenient way to represent/parse configuration from different sources. The main goals is to be very easy to use and t

Andriy Bakay 2 Sep 14, 2022
simple but convenient CLI-based Nostr client app for following users and sending DMs

nostr-commander-rs TLDR: simple but convenient CLI-based Nostr client app for publishing, sending DMs, as well as following users and channels nostr-c

null 18 Dec 30, 2022
`matchable` provides a convenient enum for checking if a piece of text is matching a string or a regex.

matchable matchable provides a convenient enum for checking if a piece of text is matching a string or a regex. The common usage of this crate is used

Pig Fang 6 Dec 19, 2022
A simple yet convenient cross-platform ARP spoofer

ruuf - A simple yet convenient cross-platform ARP spoofer Poison the ARP cache of the given victim, thereby redirecting the traffic to the target ther

null 6 Feb 19, 2023
A more convenient `#[target_feature]` replacement

A more convenient #[target_feature] replacement To get good performance out of SIMD everything on the SIMD codepath must be inlined. With how SIMD is

Koute 3 Apr 10, 2023
ChatGPT powered Rust proc macro that generates code at compile-time.

gpt-macro ChatGPT powered Rust proc macro that generates code at compile-time. Implemented Macros auto_impl!{} #[auto_test(...)] Usage Get ChatGPT API

Akira Moroo 429 Apr 15, 2023
Enhance Rust errors with file and line details using the `#[wherr]` macro for clearer debugging.

wherr Crate Discuss wherr on Hacker News Enhance Rust's ? operator by appending file and line number details to errors, simplifying the debugging proc

Joel Jakobsson 49 Sep 6, 2023
A Rust macro for quickly unwrapping a refutable pattern.

unwrap_let! A Rust macro for quickly unwrapping a refutable pattern. Install Add unwrap_let to your dependency by running cargo add unwrap_let or edit

ChainLight 10 Nov 10, 2023
Rust API Server: A versatile template for building RESTful interfaces, designed for simplicity in setup and configuration using the Rust programming language.

RUST API SERVER Introduction Welcome to the Rust API Server! This server provides a simple REST interface for your applications. This README will guid

Harry Nguyen 3 Feb 25, 2024