Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wufniks/9d8cabea849466840696fc4c2fd763c1 to your computer and use it in GitHub Desktop.
Save wufniks/9d8cabea849466840696fc4c2fd763c1 to your computer and use it in GitHub Desktop.
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