Skip to main content

IoResultExt

Trait IoResultExt 

Source
pub trait IoResultExt<T> {
    // Required method
    fn with_path(self, path: impl Into<PathBuf>) -> Result<T>;
}
Expand description

Extension trait for ergonomic conversion of io::Result<T> into the crate’s path-bearing Result<T>. Reads at call sites as std::fs::read_to_string(&path).with_path(&path)? — one extra token compared to .map_err(Error::Io)?, with much better diagnostics on failure.

Required Methods§

Source

fn with_path(self, path: impl Into<PathBuf>) -> Result<T>

Wrap an io::Error with the path that produced it, returning an Error::IoAt on failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> IoResultExt<T> for Result<T>

Source§

fn with_path(self, path: impl Into<PathBuf>) -> Result<T>

Implementors§