Skip to content

Commit 505cd8a

Browse files
committed
Add test of placement-in syntax, analogous to new-box-syntax.rs
1 parent 7a70034 commit 505cd8a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![allow(dead_code, unused_variables)]
12+
#![feature(box_heap)]
13+
#![feature(placement_in_syntax)]
14+
15+
// Tests that the new `in` syntax works with unique pointers.
16+
//
17+
// Compare with new-box-syntax.rs
18+
19+
use std::boxed::{Box, HEAP};
20+
21+
struct Structure {
22+
x: isize,
23+
y: isize,
24+
}
25+
26+
pub fn main() {
27+
let x: Box<isize> = in HEAP { 2 };
28+
let b: Box<isize> = in HEAP { 1 + 2 };
29+
let c = in HEAP { 3 + 4 };
30+
31+
let s: Box<Structure> = in HEAP {
32+
Structure {
33+
x: 3,
34+
y: 4,
35+
}
36+
};
37+
}

0 commit comments

Comments
 (0)