box_closure/
lib.rs

1//! Wrappers over `Fn`, `FnMut`, and `FnOnce` that simplify dispatching closures when `alloc` isn't available.
2//! 
3//! Typical closures are confusing, `rustc` treats them as unique even if they're identical.
4//! The closure types in `box_closure` are only opaque;
5//! `rustc` can't see through them and as long as the signitures match,
6//! they're treated as being the same closure.
7//! 
8//! This is effectively what `Box<dyn Fn ... >` does, but without allocating a `Box`.
9//! For embedded development, heap allocation is not usually an option, so `box_closure`
10//! replaces the need to box closures, instead allowing you to wrap them in `OpaqueFn`,
11//! `OpaqueFnMut`, or `OpaqueFnOnce` types to stop `rustc` from complaining about opaque types.
12//! 
13//! By being more opaque, `box_closure` stops opaque type related compiler errors.
14
15#![forbid(clippy::all)]
16#![forbid(clippy::pedantic)]
17#![forbid(clippy::nursery)]
18#![forbid(missing_docs)]
19#![no_std]
20
21mod internal;
22
23pub use internal::OpaqueFn;
24pub use internal::OpaqueFnMut;
25pub use internal::OpaqueFnOnce;
26
27pub use internal::{Align1, Align2, Align4, Align8, Align16, Align32, Align64};