https://github.com/houseabsolute/pushd
A Rust library that provides `pushd`
https://github.com/houseabsolute/pushd
Last synced: about 2 months ago
JSON representation
A Rust library that provides `pushd`
- Host: GitHub
- URL: https://github.com/houseabsolute/pushd
- Owner: houseabsolute
- License: apache-2.0
- Created: 2023-11-05T16:54:15.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-15T18:53:29.000Z (4 months ago)
- Last Synced: 2025-03-27T10:01:59.875Z (3 months ago)
- Language: Rust
- Homepage: https://docs.rs/pushd/latest/pushd/
- Size: 47.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# pushd
A simple library for temporarily changing the current working directory.
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
pushd = "0.0.1"
```## Example
```rust
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.
}
```