fu

Crates.iofu
lib.rsfu
version0.1.1
sourcesrc
created_at2024-10-11 03:15:02.249454
updated_at2024-10-11 14:38:31.22264
descriptionJust an Error
homepage
repositoryhttps://github.com/jocades/fu
max_upload_size
id1404867
size7,873
Jordi Calafat (jocades)

documentation

README

Fu

Just an Error with its location and helpful macros.

  • Custom Error type with file name, line, and column information.
  • Short and convenient macros: error!, bail!, and ensure!.
  • 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]
Commit count: 6

cargo fmt