# must fail: abr_budget_unmet_not_the_least_figure abr_budget_not_raised_past_the_budget # with nothing within the budget, the option of the least labelled figure (abr::clamp_to_budget) diff --git a/wai/wai-rs/src/http_binding/abr.rs b/wai/wai-rs/src/http_binding/abr.rs index cc9cd96a..a2ae9f56 100644 --- a/wai/wai-rs/src/http_binding/abr.rs +++ b/wai/wai-rs/src/http_binding/abr.rs @@ -398,7 +398,7 @@ pub fn clamp_to_budget(s: &AbrState, choice: usize) -> (usize, Budget) { match (0..=choice).rev().find(|&k| fig(k).is_some_and(|j| j <= b)) { Some(k) if k == choice => (k, Budget::Within), Some(k) => (k, Budget::Lowered), - None => (0, Budget::Unmet), + None => ((0..n).filter_map(|k| fig(k).map(|j| (j, k))).min().map_or(0, |(_, k)| k), Budget::Unmet), } }