Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
struct Model {
pub data: Box<[u8]>
}
struct Entity {
// ...
pub model_idx: usize
}
struct World {
entities: Vec<Entity>,
models: Vec<Model>
}
fn main() {
let model = Model { data: vec![1,2,3].into_boxed_slice() };
let entity = Entity { model_idx: 0 };
let world = World {
entities: vec![entity],
models: vec![model]
};
println!("{:?}", world.models[world.entities[0].model_idx].data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.