1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pub mod iter;
pub mod r#trait;

use sealed::sealed;

use crate::{generatable::Generatable, maybe_borrowed::MaybeBorrowed, wrapper::GenerationWrapper};

/// Some raw assert, consisting of a template, optionally some generics, and the type to assert.
pub struct RawAssert<'a, T>
where
    T: Generatable<'a>,
{
    pub template: MaybeBorrowed<'a, T>,
    pub generics: Option<MaybeBorrowed<'a, syn::Generics>>,
    pub assert: MaybeBorrowed<'a, T::Assert>,
}

#[sealed]
impl<'a, T> r#trait::RawAssertable<'a> for RawAssert<'a, T>
where
    T: Generatable<'a> + Eq + Ord,
    T::Assert: Eq + Ord,
{
    fn do_raw_assert<I>(self, store: &mut crate::store::Store<'a, I>)
    where
        I: crate::ident_generator::IdentGenerator,
    {
        store
            .generatables
            .get_or_insert_default::<GenerationWrapper<'a, T>>()
            .add_assert(self);
    }
}