Better names.
This commit is contained in:
parent
5355b4388e
commit
8e4588fc1b
14
src/main.rs
14
src/main.rs
@ -1,14 +1,14 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
trait Material {}
|
trait Material {}
|
||||||
struct Impl1 {}
|
struct MaterialImpl {}
|
||||||
impl Material for Impl1 {}
|
impl Material for MaterialImpl {}
|
||||||
|
|
||||||
trait Shape {}
|
trait Shape {}
|
||||||
struct Impl2<M: Material> {
|
struct ShapeImpl<M: Material> {
|
||||||
v: M,
|
v: M,
|
||||||
}
|
}
|
||||||
impl<M> Shape for Impl2<M> where M: Material {}
|
impl<M> Shape for ShapeImpl<M> where M: Material {}
|
||||||
impl Material for &Box<dyn Material> {}
|
impl Material for &Box<dyn Material> {}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
@ -18,10 +18,10 @@ struct State {
|
|||||||
|
|
||||||
fn load_map() -> State {
|
fn load_map() -> State {
|
||||||
let mut materials: HashMap<String, Box<dyn Material>> = HashMap::new();
|
let mut materials: HashMap<String, Box<dyn Material>> = HashMap::new();
|
||||||
materials.insert("one".to_string(), Box::new(Impl1 {}));
|
materials.insert("one".to_string(), Box::new(MaterialImpl {}));
|
||||||
materials.insert("two".to_string(), Box::new(Impl1 {}));
|
materials.insert("two".to_string(), Box::new(MaterialImpl {}));
|
||||||
|
|
||||||
let shape = Box::new(Impl2 {
|
let shape = Box::new(ShapeImpl {
|
||||||
v: materials.get("one").unwrap(),
|
v: materials.get("one").unwrap(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user