Skip to main content

frozone/
lib.rs

1#![no_std]
2mod types;
3
4pub use frozone_derive::Freezable;
5
6pub trait Freezable {
7    fn freeze() -> u64;
8}
9
10#[macro_export]
11macro_rules! assume_frozen {
12    ($t:ty) => {
13
14        impl Freezable for $t {
15            fn freeze() -> u64 {
16                use core::hash::{Hash, Hasher};
17                #[allow(deprecated)]
18                let mut h = core::hash::SipHasher::new();
19                core::any::type_name::<$t>().hash(&mut h);
20                h.finish()
21            }
22        }
23    };
24    ($($t:ty),*) => {
25        $(assume_frozen!($t);)*
26    }
27}