For the following code
#[cfg(test)]
pub(crate) mod demo {
fn use_x(x: &X) {
x.use();
}
#[test]
fn demo1() {
let x: X = X::rand();
let xr1: &X; /*start here or*/
{
xr1 = &x; /*or start here*/
}
use_x(xr1); /*last use and end here*/
}
#[test]
fn demo2() {
let x: X = X::rand();
let xr1: &X; /*start here or*/
{
xr1 = &x; /*or start here*/
use_x(xr1); /*last use here*/ /*end here or*/
}
/*or end here*/
}
}
At which lines does the lifetime of the borrowed xr1 start and end for both functions demo1 and demo2?
Note: Code successfully compiles and runs for both functions.