Module contracts

Module contracts 

Source
Expand description

§Shape Contracts.

bimm-contracts is built around the ShapeContract interface.

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§

MatcherDisplayAdapter
Display Adapter to format DimMatchers with a Index.
ShapeContract
A shape pattern, which is a sequence of terms that can match a shape.

Enums§

DimMatcher
A term in a shape pattern.