macro_rules! assert_shape_contract {
([ $($contract_expr:tt)* ], $($args:tt)*) => { ... };
($name:ident, $shape:expr, $bindings:expr $(,)?) => { ... };
}Expand description
Define and call
ShapeContract::assert_shape on a static shape
contract.
See crate::contracts::shape_contract for documentation
on the contract syntax.
See crate::contracts::ShapeContract::assert_shape for documentation on
the assertion api.
§With a Contract Expression:
use bunsen::contracts::assert_shape_contract;
let shape = [1, 2, 3, 4 * 2, 5 * 2, 3];
assert_shape_contract!(
[..., "h" = "h_win" * "ws", "w" = "w_win" * "ws", "c"],
&shape,
&[("ws", 2)],
);§With a pre-defined contract:
use bunsen::contracts::{assert_shape_contract, define_shape_contract};
let shape = [1, 2, 3, 4 * 2, 5 * 2, 3];
define_shape_contract!(
CONTRACT,
[..., "h" = "h_win" * "ws", "w" = "w_win" * "ws", "c"]);
assert_shape_contract!(CONTRACT, &shape, &[("ws", 2)]);