Skip to content

Commit

Permalink
add explicit check for index type (currently u16) capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Apr 19, 2024
1 parent f3a3e50 commit 2a60432
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ impl ContractionProcessor {
size_dict: Dict<char, f32>,
track_flops: bool,
) -> ContractionProcessor {
if size_dict.len() > Ix::MAX as usize {
panic!("cotengrust: too many indices, maximum is {}", Ix::MAX);
}

let mut nodes: Dict<Node, Legs> = Dict::default();
let mut edges: Dict<Ix, BTreeSet<Node>> = Dict::default();
let mut indmap: Dict<char, Ix> = Dict::default();
Expand Down

0 comments on commit 2a60432

Please sign in to comment.