mod traits {
#[hazmat::suit]
pub trait AddOnce {
fn add_once(self, other: &Self) -> Self;
}
pub trait AddTwice {
fn add_twice(self, other: &Self) -> Self;
}
impl<T: AddOnce> AddTwice for T {
fn add_twice(self, other: &Self) -> Self {
self.add_once(other, AddOnceCap).add_once(other, AddOnceCap)
}
}
}
#[derive(Debug, PartialEq)]
struct Num(u32);
#[hazmat::suit]
impl traits::AddOnce for Num {
fn add_once(self, other: &Self) -> Self {
Self(self.0 + other.0)
}
}
#[test]
fn test_high_level() {
use crate::traits::AddTwice;
let a = Num(7);
let b = Num(15);
let c = Num(37);
assert_eq!(a.add_twice(&b), c);
}