Created
May 30, 2018 17:52
-
-
Save wufniks/9d8cabea849466840696fc4c2fd763c1 to your computer and use it in GitHub Desktop.
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
struct Elem(u32); | |
struct Slotmap { | |
data: Vec<Elem>, | |
} | |
impl Slotmap { | |
fn get(&self) -> &Elem { | |
&self.data[0] | |
} | |
} | |
struct Index { | |
reference: Slotmap, | |
table: u32, | |
} | |
impl Index { | |
fn foo(&mut self) { | |
let elem = self.reference.get(); | |
//let r = self.reference; | |
let t = &mut self.table; | |
} | |
} | |
fn main() { | |
let mut idx = Index { | |
reference: Slotmap { | |
data: vec![Elem(1), Elem(2), Elem(3)], | |
}, | |
table: 42, | |
}; | |
idx.foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment