anystack 0.6.0-alpha.3

Flexible and comprehensive error handling.
Documentation
#![cfg_attr(doc, doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md")))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(all(doc, nightly), feature(doc_auto_cfg, doc_cfg))]
#![cfg_attr(
    not(miri),
    doc(test(attr(
        deny(warnings, clippy::pedantic, clippy::nursery),
        allow(exported_private_dependencies)
    )))
)]
#![allow(unsafe_code)]
// This is an error handling library producing Results, not Errors
#![allow(clippy::missing_errors_doc)]

extern crate alloc;

pub mod future;
pub mod iter;

mod compat;
mod frame;
mod macros;
mod report;
mod result;

mod context;
mod error;
pub mod fmt;
#[cfg(any(feature = "std", feature = "hooks"))]
mod hook;
#[cfg(feature = "serde")]
mod serde;

#[expect(deprecated, reason = "`core::error::Error` is stable now")]
pub use self::context::Context;
#[expect(deprecated, reason = "We are moving to a more explicit API")]
pub use self::result::Result;
pub use self::result::ResultStack;
pub use self::{
    compat::IntoReportCompat,
    frame::{AttachmentKind, Frame, FrameKind},
    report::{IntoReport, Report},
};
#[doc(inline)]
pub use self::{future::FutureExt, result::ResultExt};

#[cfg(test)]
#[expect(dead_code)]
mod tests {

    use core::{error::Error, mem};

    use crate::Report;

    const fn assert_send<T: Send>() {}

    const fn assert_sync<T: Sync>() {}

    const fn assert_static<T: 'static>() {}

    const fn report() {
        assert_send::<Report<()>>();
        assert_sync::<Report<()>>();
        assert_static::<Report<()>>();
        assert_send::<Report<dyn Error>>();
        assert_sync::<Report<dyn Error>>();
        assert_static::<Report<dyn Error>>();
    }

    #[test]
    fn size() {
        assert_eq!(mem::size_of::<Report<()>>(), mem::size_of::<*const ()>());
        assert_eq!(
            mem::size_of::<Report<dyn Error>>(),
            mem::size_of::<*const ()>()
        );
    }
}