| 81 | |
| 82 | impl<T, const L: u32, const H: u32> VecInRange<T, L, H> { |
| 83 | fn new<'a>( |
| 84 | input: &mut Unstructured<'a>, |
| 85 | fuel: &mut u32, |
| 86 | generate: impl Fn(&mut Unstructured<'a>, &mut u32) -> arbitrary::Result<T>, |
| 87 | ) -> arbitrary::Result<Self> { |
| 88 | let mut ret = Vec::new(); |
| 89 | input.arbitrary_loop(Some(L), Some(H), |input| { |
| 90 | if *fuel > 0 { |
| 91 | *fuel = *fuel - 1; |
| 92 | ret.push(generate(input, fuel)?); |
| 93 | Ok(std::ops::ControlFlow::Continue(())) |
| 94 | } else { |
| 95 | Ok(std::ops::ControlFlow::Break(())) |
| 96 | } |
| 97 | })?; |
| 98 | Ok(Self(ret)) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | impl<T, const L: u32, const H: u32> Deref for VecInRange<T, L, H> { |