| Crates.io | pushd |
| lib.rs | pushd |
| version | 0.0.2 |
| created_at | 2023-11-06 03:27:43.375834+00 |
| updated_at | 2024-12-08 20:31:07.543952+00 |
| description | A library that implements pushd |
| homepage | |
| repository | https://github.com/houseabsolute/pushd |
| max_upload_size | |
| id | 1026324 |
| size | 39,393 |
A simple library for temporarily changing the current working directory.
Add this to your Cargo.toml:
[dependencies]
pushd = "0.0.1"
use anyhow::Result
use std::path::PathBuf;
use pushd::Pushd;
fn main() -> Result<()> {
write_in_etc()?;
// Current working directory is whatever it was before the call to
// `write_in_etc`.
}
fn write_in_etc() -> Result<()> {
let path = PathBuf::new("/etc");
let _pd = Pushd::new(path)?;
// Current working directory is now /etc
//
// Do something in /etc.
}