Browse Source

Error handling for required piece that is too large

master
Stephen 1 week ago
parent
commit
cd3cb59d65
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      src/main.rs

+ 10
- 1
src/main.rs View File

@ -226,7 +226,16 @@ fn find_best_cuts<'a>(
required: Vec<Req1D<'a>>,
blade_width: f64,
) -> String {
// TODO check that all in required are <= length of available
// Check that all in required are <= length of available
let avail_max = available
.iter()
.map(|x| x.remaining)
.fold(f64::NAN, f64::max);
for r in &required {
if r.length > avail_max {
panic!("Error: One of your required pieces is larger than all available pieces.");
}
}
let start_state = State {
lumber: Vec::new(),


Loading…
Cancel
Save