2024-02-20 14:19:16 +00:00
|
|
|
//@ check-pass
|
|
|
|
|
|
|
|
fn temp() -> (String, i32) {
|
|
|
|
(String::from("Hello"), 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a = &temp();
|
|
|
|
let b = [(&temp(),)];
|
|
|
|
let c = &temp().0;
|
|
|
|
let d = &temp().0[..];
|
|
|
|
let e = {
|
|
|
|
let _ = 123;
|
|
|
|
&(*temp().0)[..]
|
|
|
|
};
|
|
|
|
let f = if true {
|
|
|
|
&temp()
|
|
|
|
} else {
|
|
|
|
&temp()
|
|
|
|
};
|
|
|
|
let g = match true {
|
|
|
|
true => &temp(),
|
|
|
|
false => {
|
|
|
|
let _ = 123;
|
|
|
|
&temp()
|
|
|
|
}
|
|
|
|
};
|
2024-02-20 15:22:04 +00:00
|
|
|
let h = match temp() {
|
2024-02-20 15:23:05 +00:00
|
|
|
// The {} moves the value, making a new temporary.
|
2024-02-20 15:22:04 +00:00
|
|
|
owned_non_temporary => &{ owned_non_temporary },
|
|
|
|
};
|
|
|
|
println!("{a:?} {b:?} {c:?} {d:?} {e:?} {f:?} {g:?} {h:?}");
|
2024-02-20 14:19:16 +00:00
|
|
|
}
|