rust/tests/ui/regions/regions-infer-borrow-scope-within-loop-ok.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
185 B
Rust
Raw Normal View History

//@ run-pass
fn borrow<T>(x: &T) -> &T {x}
2012-07-06 16:14:57 +00:00
pub fn main() {
let x: Box<_> = Box::new(3);
2012-07-06 16:14:57 +00:00
loop {
let y = borrow(&*x);
assert_eq!(*x, *y);
break;
2012-07-06 16:14:57 +00:00
}
}