Created
February 5, 2013 02:20
-
-
Save jbclements/4711572 to your computer and use it in GitHub Desktop.
this doesn't trigger the bug... maybe splitting it over multiple files?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait HasGet { | |
fn get(&self) -> int; | |
} | |
pub type struct_inr = @StructInr; | |
pub struct StructInr { | |
x : int | |
} | |
pub impl StructInr : HasGet { | |
fn get(&self) -> int { | |
self.x | |
} | |
} | |
pub fn new_struct_inr () -> struct_inr { | |
@StructInr{x : 3} | |
} | |
#[test] | |
fn t1 () { | |
let t : struct_inr = new_struct_inr(); | |
assert t.get() == 3; | |
} | |
pub type struct_outer = @StructOuter; | |
pub struct StructOuter { | |
substruct : @StructInr | |
} | |
impl StructOuter : HasGet { | |
fn get(&self) -> int { | |
self.substruct.get() | |
} | |
} | |
pub fn new_struct_outer () -> HasGet { | |
(@StructOuter {substruct : new_struct_inr ()}) as HasGet | |
} | |
#[test] | |
fn t2 () { | |
let t = new_struct_outer(); | |
assert t.get() == 3; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment