Skip to main content

from_err

Macro from_err 

Source
macro_rules! from_err {
    ($from:ty, $to:tt, $var:tt) => { ... };
}
Expand description

A macro that implements the From trait for converting from one error type to another.

ยงUsage


use umya_spreadsheet::from_err;

#[derive(Debug)]
enum MyError {
    Io(std::io::Error),
};

from_err!(std::io::Error, MyError, Io);

let io_err = io::Error::new(io::ErrorKind::Other, "An I/O error occurred");
let my_err: MyError = io_err.into();