Will the following code compile?
fn identity(t: T) -> T { t } fn main() { println!("{} {:?} {}", identity(5), identity([1,2,3]), identity("hello")) }
Why does the following function successfully compile?
fn f() -> &'static str { "hello" }
Fill in the blank so that the struct defined below is explicitly cloneable.
#[derive()] struct S { string: String, opt: Option, res: Result }
True or false:
The lifetime of a reference is independent of its original variable's lifetime.
Will the following compile?
fn f<'a, T>(arr: &'a Vec< T >) -> &'a T where T: Copy { &arr[0] } fn main() { let mut v = vec![]; v.push(String::from("This is a string!")); println!("{}", f(&v)) }