Crate formality_core
source ·Expand description
formality-core
contains core definitions that can be used for
languages that are not Rust. It is intended to play a role similar
to
Modules
- Manages binders so that the main rules can be nice and simple.
- Attach a span to a
std::future::Future
.
Macros
- Return early with an error.
- Constructs an event at the debug level.
- Declares a new formality language. This will generate a module with a name you choose that contains various items; among them will be a struct named
FormalityLang
that implements theLanguage
trait. When you use the auto-derives or theterm
macro, they will generate code that referencescrate::FormalityLang
, so you need to bring that in scope at the root of your crate (e.g., if you called the modulemylang
, you might adduse crate::mylang::FormalityLang
at the root of your crate, so that the auto-derives can find it.) - Declares a newtyped struct that is an arbitrary (string) identifier, like the name of a module or something.
- push_rules! allows construction of inference rules using a more logic-like notation.
- Replacement for the
vec
macro that supports..foo
notation to flatten vectors. - Constructs an event at the trace level.
Traits
- This is the convenience trait whose method you should call to do a downcast.
- Our version of “try-from”. A “downcast” casts from a more general type (e.g., any Parameter) to a more specific type (e.g., a type). This returns an Option because the value may not be an instance of the more specific type.
- Our version of “try-into”. A “downcast” casts from a more general type (e.g., any Parameter) to a more specific type (e.g., a type).
- Our version of
Into
. This is the trait you use in where clauses, but you typically implementUpcastFrom
. - Our version of
From
. One twist: it is implemented for &T for all T. This is the trait you implement.
Functions
- Run an action with a tracing log subscriber. The logging level is loaded from
RUST_LOG
. Theformality_macro::test
expansion uses this to enable logs.
Type Aliases
Attribute Macros
- Instruments a function to create and enter a
tracing
span every time the function is called. - Pre-conditions are checked before the function body is run.