Hard
Shortening an element lifetime behind &'a Vec vs. &'a mut Vec
Which of these two functions compile?
main.rs
fn shorten<'a>(v: &'a Vec<&'static str>) -> &'a Vec<&'a str> {
v
}
fn shorten_mut<'a>(v: &'a mut Vec<&'static str>) -> &'a mut Vec<&'a str> {
v
}
fn main() {
let mut names: Vec<&'static str> = vec!["alpha"];
println!("{}", shorten(&names).len());
println!("{}", shorten_mut(&mut names).len());
}50 of 53 in Rust