fn lifetimes_interesting() {
    let mut data = vec![1, 2, 3];
    let x = &data[0];
    data.push(4);
    // println!("{}", x);
}
//* Example 2: Problem: we have a live shared reference x to
//* a descendant of data when we try to take a mutable
//* reference to data to push.
//? Subtle and interesting example: if we swap print and push,
//? it works, the reason is 'x' is no longer needed. Although
//? this works, 'x' exists till the end of the scope.
//? However if the value has a destructor, running the destructor
//? is considered a use that is run at the end of the scope,
//? therefore this will not compile.
Example 2: Problem: we have a live shared reference x to
a descendant of data when we try to take a mutable
reference to data to push.
? Subtle and interesting example: if we swap print and push,
? it works, the reason is 'x' is no longer needed. Although
? this works, 'x' exists till the end of the scope.
? However if the value has a destructor, running the destructor
? is considered a use that is run at the end of the scope,
? therefore this will not compile.
Example 2 : Problem : we have a live shared reference x to a descendant of data when we try to take a mutable reference to data to push . ? Subtle and interesting example : if we swap print and push ? it works the reason is ' x ' is no longer needed . Although ? this works ' x ' exists till the end of the scope . ? However if the value has a destructor running the destructor ? is considered a use that is run at the end of the scope ? therefore this will not compile .
fn lifetimes_interesting() {
    let mut data = vec![1, 2, 3];
    let x = &data[0];
    data.push(4);
    // println!("{}", x);
}
fn lifetimes_interesting ( ) { let mut data = vec ! [ 1 2 3 ] ; let x = & data [ 0 ] ; data . push ( 4 ) ; // println!("{}", x); }
Example 2: Problem: we have a live shared reference x to
a descendant of data when we try to take a mutable
reference to data to push.
Example 2 : Problem : we have a live shared reference x to a descendant of data when we try to take a mutable reference to data to push .