rust/tests/ui/expr-block.rs

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

19 lines
466 B
Rust
Raw Normal View History

// run-pass
2020-03-27 20:56:19 +00:00
#![allow(unused_braces)]
#![allow(dead_code)]
// Tests for standalone blocks as expressions
2013-03-29 01:39:09 +00:00
fn test_basic() { let rs: bool = { true }; assert!((rs)); }
struct RS { v1: isize, v2: isize }
fn test_rec() { let rs = { RS {v1: 10, v2: 20} }; assert_eq!(rs.v2, 20); }
fn test_filled_with_stuff() {
2015-01-25 21:05:03 +00:00
let rs = { let mut a = 0; while a < 10 { a += 1; } a };
assert_eq!(rs, 10);
}
pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }