Expand description
§Shape Contracts.
bimm-contracts is built around the ShapeContract interface.
- A
ShapeContractis a sequence ofDimMatchers. - A
DimMatchermatches one or more dimensions of a shape:DimMatcher::Anymatches any dimension size.DimMatcher::Ellipsismatches a variable number of dimensions (ellipsis).DimMatcher::Exprmatches a dimension expression that must match a specific value.
A ShapeContract should usually be constructed using the crate::shape_contract macro.
§Example
use bimm_contracts::{shape_contract, ShapeContract};
static CONTRACT : ShapeContract = shape_contract![
...,
"height" = "h_wins" * "window",
"width" = "w_wins" * "window",
"channels",
];
let shape = [1, 2, 3, 2 * 8, 3 * 8, 4];
// Assert the shape, given the bindings.
let [h_wins, w_wins] = CONTRACT.unpack_shape(
&shape,
&["h_wins", "w_wins"],
&[("window", 8)]
);
assert_eq!(h_wins, 2);
assert_eq!(w_wins, 3);Structs§
- Matcher
Display Adapter - Display Adapter to format
DimMatcherswith aIndex. - Shape
Contract - A shape pattern, which is a sequence of terms that can match a shape.
Enums§
- DimMatcher
- A term in a shape pattern.