proc_macro_assertions/lib.rs
1//! This crate makes it easy to check inputs of proc macros for some conditions. It works by generating const
2//! code which is never actually executed but the type checking of it ensures the conditions are met.
3//!
4//! For more information see the [Static Assertions](https://docs.rs/static_assertions) crate. (Disclaimer: I am not affiliated with the author of that crate in any way)
5//!
6//! The core type of this crate is the Assertion [`Store`](crate::store::Store), which contains all the asserts that are
7//! generated and then later turned into tokens.
8//!
9//! For the included types of assertions it's recommended to use the [`assert_into!`](macro@crate::assert_into) macro.
10//!
11//! The documentation of the individual items in this crate is pretty ok-ish, a funtional overview on how it works
12//! will be provided once I've got the time to draw that up. So for now just take a look at the individual types.
13//!
14//! # Example
15//! ```
16//! pub use proc_macro_assertions::prelude::*;
17//!
18//! let type_to_test: syn::Type = syn::parse_quote!(String);
19//! let store = DefaultStore::new();
20//! assert_into!(store | &type_to_test impl std::default::Default);
21//! assert_into!(store | &type_to_test == String);
22//! let tokens = quote::quote!{ #store };
23//! ```
24
25#![warn(clippy::pedantic)]
26#![warn(clippy::nursery)]
27
28pub mod add_generics;
29pub mod assert;
30pub mod assert_into;
31pub mod assertable;
32pub mod bounds;
33pub mod context;
34pub mod generatable;
35pub mod ident_generator;
36pub mod into_template;
37pub mod maybe_borrowed;
38pub mod passed_data;
39pub mod raw_assert;
40pub mod store;
41pub mod token_cmp_wrapper;
42
43mod generatable_set;
44mod token_store;
45mod wrapper;
46
47pub mod ext {
48 pub use syn;
49}
50
51pub mod prelude {
52 pub use super::add_generics::AttachGenerics;
53 pub use super::add_generics::WithGenerics;
54 pub use super::assert::Assert;
55 pub use super::assert::InsertIntoTemplate;
56 pub use super::assert_into;
57 pub use super::assertable::Assertable;
58 pub use super::bounds::AssertableWithBounds;
59 pub use super::bounds::ProvideBounds;
60 pub use super::bounds::ResolveBounds;
61 pub use super::bounds::ResolvedBounds;
62 pub use super::generatable::Generatable;
63 pub use super::generatable::Trait;
64 pub use super::generatable::Type;
65 pub use super::raw_assert::r#trait::RawAssertable;
66 pub use super::raw_assert::RawAssert;
67 pub use super::store::DefaultStore;
68 pub use super::store::Store;
69}