ohno 0.3.5

High-quality Rust error handling.
Documentation
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Example demonstrating how to disable default constructors.
//!
//! Shows the `#[no_constructors]` attribute to opt-out of default behavior.

use ohno::{Error, OhnoCore};

#[derive(Error)]
#[no_constructors]
struct MyError {
    inner: OhnoCore,
}

fn failing_function() -> Result<(), MyError> {
    // Must construct manually when constructors are disabled
    Err(MyError {
        inner: OhnoCore::from("Manually constructed error"),
    })
}

#[expect(clippy::unwrap_used, reason = "Example code")]
fn main() {
    let e = failing_function().unwrap_err();
    println!("Error: {e}");
}