Crates.io | rustypath |
lib.rs | rustypath |
version | 0.1.1 |
source | src |
created_at | 2024-05-07 09:43:35.893447 |
updated_at | 2024-05-07 10:16:22.146235 |
description | Easily manage paths in rust |
homepage | |
repository | https://github.com/d33pster/rustypath |
max_upload_size | |
id | 1232029 |
size | 11,802 |
Path crate for rust. Managing paths made easy.
Coverting and Managing paths in rust is now made easy.
cargo add rustypath
use rustypath::RPath;
// to create a new RPath
let rpath = RPath::new_from("/abc");
// to create from Path (std::path::Path)
let demopath = Path::from("/abc");
let rpath = RPath::new_from_path(demopath);
// to create from PathBuf
let demopbuf = PathBuf::from("/abc");
let rpath = RPath::new_from_pbuf(demopbuf);
// join more parts to it
let new_r_path = rpath.join("bca"); //will return /abc/bca
// convert to pathbuf
let pbuf = rpath.convert_to_pathbuf();
// convert to string
let string = rpath.convert_to_string();
// convert from relpath to abspath
let abspath = rpath.expand()
// convert from Option<PathBuf> to PathBuf
// suppose u get some output in Option<Pathbuf>
let pbuf = RPath::convert_optionpathbuf_to_pbuf(p:Option<PathBuf>);
// get current dir in RPath
let current_working_dir = RPath::pwd();
// get home dir in RPath
let homedir = RPath::gethomedir();
// get clone
let rpath2 = rpath.clone();