Pick the largest supported dim ≤ `requested`. Returns the full dim (last in the list) when `requested` is `None`. Returns the smallest available dim when `requested` is smaller than all supported dims.
(&self, requested: Option<u32>)
| 46 | /// Returns the smallest available dim when `requested` is smaller than |
| 47 | /// all supported dims. |
| 48 | pub fn pick(&self, requested: Option<u32>) -> u32 { |
| 49 | let Some(req) = requested else { |
| 50 | return *self.truncation_dims.last().copied().get_or_insert(0); |
| 51 | }; |
| 52 | // Find largest dim that is ≤ req. |
| 53 | self.truncation_dims |
| 54 | .iter() |
| 55 | .rev() |
| 56 | .find(|&&d| d <= req) |
| 57 | .copied() |
| 58 | .unwrap_or_else(|| self.truncation_dims.first().copied().unwrap_or(req)) |
| 59 | } |
| 60 | |
| 61 | /// Return `true` if `dim` is one of the supported truncation dims. |
| 62 | pub fn is_valid(&self, dim: u32) -> bool { |