Cut down on macro nonsense

- InertAtomic replaced atomic_inert! for improved tooling support
- atomic_defaults! is easier to type out than to explain in a docstring
- Changed rustfmt config to better support tiny functions such as as_any
This commit is contained in:
2023-09-15 12:37:10 +01:00
parent 3c0056c2db
commit 0bcf10659b
73 changed files with 418 additions and 654 deletions

View File

@@ -4,11 +4,11 @@ use std::fmt::Debug;
use trait_set::trait_set;
use super::{Atomic, ExternFn, XfnResult};
use super::{Atomic, ExternFn, InertAtomic, XfnResult};
use crate::interpreted::{Clause, ExprInst};
use crate::interpreter::{Context, HandlerRes};
use crate::utils::pure_push::pushed_ref;
use crate::{ConstTree, atomic_inert};
use crate::ConstTree;
trait_set! {
/// A "well behaved" type that can be used as payload in a CPS box
@@ -34,9 +34,7 @@ impl<T: CPSPayload> CPSFn<T> {
}
}
impl<T: CPSPayload> ExternFn for CPSFn<T> {
fn name(&self) -> &str {
"CPS function without argument"
}
fn name(&self) -> &str { "CPS function without argument" }
fn apply(&self, arg: ExprInst, _ctx: Context) -> XfnResult {
let payload = self.payload.clone();
let continuations = pushed_ref(&self.continuations, arg);
@@ -93,7 +91,9 @@ impl<T: CPSPayload> CPSBox<T> {
}
}
atomic_inert!(CPSBox(T:(CPSPayload)), typestr = "a CPS box");
impl<T: CPSPayload> InertAtomic for CPSBox<T> {
fn type_str() -> &'static str { "a CPS box" }
}
/// Like [init_cps] but wrapped in a [ConstTree] for init-time usage
pub fn const_cps<T: CPSPayload>(argc: usize, payload: T) -> ConstTree {