[−][src]Macro canrun::domains::domain
domain!() { /* proc-macro */ }
Generate Domain structs and other associated types and impls.
Manually implementing a Domain would be tedious and finicky. This macro attempts to simplify most of the general cases by building out everything required to reason about values of various types.
A few example domains are available for simple use cases.
Examples
Begin each declaration with the domain keyword.
canrun::domain! { MyDomain { i32 } }
The optional visibility modifier works just as in normal Rust.
canrun::domain! { pub MyPublicDomain { i32 } }
You can define multiple values, include structures. Note that a wrapping
Val
is required in the tuple.
use canrun::Val; canrun::domain! { pub MyBigDomain { i32, String, (Val<i32>, Val<String>), } }
Any types you add to a domain must implement the
UnifyIn
trait. Canrun includes default
implementations for almost all primitive types and collection types are
available in [canrun_collections
].
Once you have a domain, you can use it to parameterize other types, such as
State
and Goal
:
let state: State<MyDomain> = State::new(); let goal: Goal<MyDomain> = unify(x, 1);
Generate Domain
structs and other
associated types and impls.
See the Canrun docs for details.