Expand description
§Fu
Just an Error with its location and helpful macros.
- Custom
Errortype with file name, line, and column information. - Short and convenient macros:
error!,bail!, andensure!. - Lightweight.
§Usage
ⓘ
use fu::{bail, ensure, Result};
const MAX: i32 = 10;
fn example(value: i32) -> Result<()> {
ensure!(value >= 0, "value must be non-negative");
if value > MAX {
bail!("value is larger than {}", MAX);
}
Ok(())
}
fn main() -> Result<()> {
example(-1)
}
// Error: value must be non-negative examples/foo.rs:[4:5]Macros§
- bail
- Return early with an error.
- ensure
- Return early with an error if a condition is not satisfied.
- error
- Construct a Result with the crates
Errortype.
Structs§
- Error
- A custom error type that contains file location and a message.