You need slice patterns:
fn vec_alt<T>(vals: Vec<T>) -> &'static str {
match vals[..] {
[a, b] => "two elements",
[a, b, c] => "three elements",
_ => "otherwise",
}
}
You need slice patterns:
fn vec_alt<T>(vals: Vec<T>) -> &'static str {
match vals[..] {
[a, b] => "two elements",
[a, b, c] => "three elements",
_ => "otherwise",
}
}