]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/init-res-into-things.rs
1 #![allow(non_camel_case_types)]
3 #![feature(box_syntax)]
7 // Resources can't be copied, but storing into data structures counts
8 // as a move unless the stored thing is used afterwards.
14 struct BoxR
<'a
> { x: r<'a> }
16 impl<'a
> Drop
for r
<'a
> {
18 self.i
.set(self.i
.get() + 1)
22 fn r(i
: &Cell
<isize>) -> r
{
29 let i
= &Cell
::new(0);
31 let _a
= BoxR {x: r(i)}
;
33 assert_eq
!(i
.get(), 1);
41 let i
= &Cell
::new(0);
45 assert_eq
!(i
.get(), 1);
49 let i
= &Cell
::new(0);
53 assert_eq
!(i
.get(), 1);
57 let i
= &Cell
::new(0);
59 let _a
: Box
<_
> = box r(i
);
61 assert_eq
!(i
.get(), 1);
64 fn test_unique_rec() {
65 let i
= &Cell
::new(0);
67 let _a
: Box
<_
> = box BoxR
{
71 assert_eq
!(i
.get(), 1);