Expand description
§Design-by-Contract for Rust
Design by Contract is a programming methodology
which binds the caller and the function called to a
contract. The contract is represented using Hoare Triple:
{P} C {Q}
, where {P}
is the precondition before
executing command C
, and {Q}
is the postcondition.
Like debug_assert!
, dbc macros are only enabled in non
optimized builds by default. An optimized build will omit all
dbc macro statements unless -C debug-assertions
is passed to the
compiler.
§See Also
- http://en.wikipedia.org/wiki/Design_by_contract
- http://en.wikipedia.org/wiki/Hoare_logic
- https://dlang.org/spec/contracts.html
§Note
This library is similar to my godbc for Golang.
Macros§
- Postcondition tests
- Stringify one or more variables and their values
- Invariant condition assertion
- Precondondition tests
Traits§
- The
Invariant
trait allows for asserting an object