Created
November 8, 2019 17:37
-
-
Save rust-play/348ea8d489773fcd46ccd25c39683d5f to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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 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