Preparation for sharing

- rustfmt
- clippy
- comments
- README
This commit is contained in:
2023-05-25 19:14:24 +01:00
parent e99ade92ba
commit bc2714aad8
144 changed files with 3734 additions and 3243 deletions

View File

@@ -1,40 +1,36 @@
use super::super::Numeric;
use std::fmt::Debug;
use crate::{atomic_impl, atomic_redirect, externfn_impl};
use super::super::Numeric;
use crate::representations::interpreted::ExprInst;
use crate::{atomic_impl, atomic_redirect, externfn_impl};
/// Remainder function
///
/// Takes the modulus of two numbers.
///
/// Next state: [Remainder1]
#[derive(Clone)]
pub struct Remainder2;
externfn_impl!(Remainder2, |_: &Self, x: ExprInst| Ok(Remainder1{x}));
externfn_impl!(Remainder2, |_: &Self, x: ExprInst| Ok(Remainder1 { x }));
/// Partially applied Remainder function
///
/// Prev state: [Remainder2]; Next state: [Remainder0]
#[derive(Debug, Clone)]
pub struct Remainder1{ x: ExprInst }
pub struct Remainder1 {
x: ExprInst,
}
atomic_redirect!(Remainder1, x);
atomic_impl!(Remainder1);
externfn_impl!(Remainder1, |this: &Self, x: ExprInst| {
let a: Numeric = this.x.clone().try_into()?;
Ok(Remainder0{ a, x })
Ok(Remainder0 { a, x })
});
/// Fully applied Remainder function.
///
/// Prev state: [Remainder1]
#[derive(Debug, Clone)]
pub struct Remainder0 { a: Numeric, x: ExprInst }
pub struct Remainder0 {
a: Numeric,
x: ExprInst,
}
atomic_redirect!(Remainder0, x);
atomic_impl!(Remainder0, |Self{ a, x }: &Self, _| {
atomic_impl!(Remainder0, |Self { a, x }: &Self, _| {
let b: Numeric = x.clone().try_into()?;
Ok((*a % b).into())
});
});