(layers: &[String])
| 211 | // --------------------------------------------------------------------------- |
| 212 | |
| 213 | fn layers_to_range(layers: &[String]) -> String { |
| 214 | if layers.is_empty() { |
| 215 | return "none".to_string(); |
| 216 | } |
| 217 | let first_num = layers.first().and_then(|l| l.rsplit('.').next()).and_then(|n| n.parse::<usize>().ok()); |
| 218 | let last_num = layers.last().and_then(|l| l.rsplit('.').next()).and_then(|n| n.parse::<usize>().ok()); |
| 219 | match (first_num, last_num) { |
| 220 | (Some(f), Some(l)) if f == l => format!("layer {}", f), |
| 221 | (Some(f), Some(l)) => format!("layers {}–{} ({} total)", f, l, layers.len()), |
| 222 | _ => format!("{} layer(s)", layers.len()), |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | // --------------------------------------------------------------------------- |
| 227 | // Public entry point |
no outgoing calls
no test coverage detected