[][src]Struct chwd::ChangeWorkingDirectory

pub struct ChangeWorkingDirectory { /* fields omitted */ }

Implementations

impl ChangeWorkingDirectory[src]

pub fn change(new_directory: &impl AsRef<Path>) -> Result<Self, Error>[src]

Store the current working directory, then change it to the supplied path. When the struct goes out of scope, the current working directory will be changed back to what it originally was.

use std::env;
use chwd::ChangeWorkingDirectory;
use std::io;

fn main() -> Result<(), std::io::Error>
{
    {
        let _dir_change = ChangeWorkingDirectory::change(&env::temp_dir())?;
        // Do something in the temp dir
    }

    // _dir_change has gone out of scope, you will be back where you started.
    Ok(())
}

Trait Implementations

impl Debug for ChangeWorkingDirectory[src]

impl Drop for ChangeWorkingDirectory[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.