fn with_file(path: PathBuf) -> Result<History, WrashError> {
        let s = match fs::read_to_string(path.as_path()) {
            Ok(s) => s,
            Err(err) => {
                // ignore any issues with a missing history file
                if err.kind() == ErrorKind::NotFound {
                    String::new()
                } else {
                    return Err(WrashError::FailedIo(err));
                }
            }
        };

        let history = if s.is_empty() {
            vec![]
        } else {
            match serde_yaml::from_str(s.as_str()) {
                Ok(history) => history,
                Err(err) => return Err(WrashError::Custom(err.to_string())),
            }
        };

        Ok(Self {
            history,
            path: Some(path),
        })
    }
/// Construct a new `History` file using the given file as the source. If
/// the file cold not be found or read, the history is created empty, and
/// the target file is also created.
Construct a new `History` file using the given file as the source. If
the file cold not be found or read, the history is created empty, and
the target file is also created.
Construct a new ` History ` file using the given file as the source . If the file cold not be found or read the history is created empty and the target file is also created .
fn with_file(path: PathBuf) -> Result<History, WrashError> {
        let s = match fs::read_to_string(path.as_path()) {
            Ok(s) => s,
            Err(err) => {
                // ignore any issues with a missing history file
                if err.kind() == ErrorKind::NotFound {
                    String::new()
                } else {
                    return Err(WrashError::FailedIo(err));
                }
            }
        };
        let history = if s.is_empty() {
            vec![]
        } else {
            match serde_yaml::from_str(s.as_str()) {
                Ok(history) => history,
                Err(err) => return Err(WrashError::Custom(err.to_string())),
            }
        };
        Ok(Self {
            history,
            path: Some(path),
        })
    }
fn with_file ( path : PathBuf ) -> Result < History , WrashError > { let s = match fs :: read_to_string ( path . as_path ( ) ) { Ok ( s ) => s , Err ( err ) => { // ignore any issues with a missing history file if err . kind ( ) == ErrorKind :: NotFound { String :: new ( ) } else { return Err ( WrashError :: FailedIo ( err ) ) ; } } } ; let history = if s . is_empty ( ) { vec ! [ ] } else { match serde_yaml :: from_str ( s . as_str ( ) ) { Ok ( history ) => history , Err ( err ) => return Err ( WrashError :: Custom ( err . to_string ( ) ) ) , } } ; Ok ( Self { history , path : Some ( path ) , } ) }
Construct a new `History` file using the given file as the source.
Construct a new ` History ` file using the given file as the source .
path
PathBuf