Public API and docs

This commit is contained in:
2023-05-26 15:23:15 +01:00
parent 3c1a6e2be2
commit fdf18e6ff8
99 changed files with 503 additions and 406 deletions

View File

@@ -0,0 +1,36 @@
use std::fmt::Debug;
use super::super::Numeric;
use crate::representations::interpreted::ExprInst;
use crate::{atomic_impl, atomic_redirect, externfn_impl};
/// Adds two numbers
///
/// Next state: [Add1]
#[derive(Clone)]
pub struct Add2;
externfn_impl!(Add2, |_: &Self, x: ExprInst| Ok(Add1 { x }));
/// Prev state: [Add2]; Next state: [Add0]
#[derive(Debug, Clone)]
pub struct Add1 {
x: ExprInst,
}
atomic_redirect!(Add1, x);
atomic_impl!(Add1);
externfn_impl!(Add1, |this: &Self, x: ExprInst| {
let a: Numeric = this.x.clone().try_into()?;
Ok(Add0 { a, x })
});
/// Prev state: [Add1]
#[derive(Debug, Clone)]
pub struct Add0 {
a: Numeric,
x: ExprInst,
}
atomic_redirect!(Add0, x);
atomic_impl!(Add0, |Self { a, x }: &Self, _| {
let b: Numeric = x.clone().try_into()?;
Ok((*a + b).into())
});