Skip to content

Instantly share code, notes, and snippets.

@jbclements
Created February 5, 2013 02:20
Show Gist options
  • Save jbclements/4711572 to your computer and use it in GitHub Desktop.
Save jbclements/4711572 to your computer and use it in GitHub Desktop.
this doesn't trigger the bug... maybe splitting it over multiple files?
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