Browse Source

move to string

Johann Woelper 5 years ago
parent
commit
89abcd9eef
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/main.rs

+ 8 - 4
src/main.rs

@@ -11,7 +11,7 @@ use nalgebra::Vector3;
 
 #[derive(Clone, Debug, Default)]
 struct Voxel {
-    id: &'static str,
+    id: String,
     adjacency: HashMap<&'static str, u16>,
 }
 
@@ -56,12 +56,16 @@ fn load_export(path: &'static str) -> HashMap<Vector3<i32>, String> {
 fn main() {
 
     let mut vol: HashMap<Vector3<i32>, Voxel> = HashMap::new();
-    vol.insert(Vector3::new(1,0,0), Voxel {id: "border_left", ..Default::default()});
-    vol.insert(Vector3::new(1,0,1), Voxel {id: "straight", ..Default::default()});
+    vol.insert(Vector3::new(1,0,0), Voxel {id: "border_left".to_string(), ..Default::default()});
+    vol.insert(Vector3::new(1,0,1), Voxel {id: "straight".to_string(), ..Default::default()});
 
 
-    let exp = load_export("out.json");
+    for (pos, tile) in load_export("out.json") {
+        // dbg!(&pos, &tile);
+        vol.insert(pos, Voxel {id: tile, ..Default::default()});
+    }
 
+    dbg!(&vol);
     // let mut adj_map: HashMap<String, Adjacency> = HashMap::new();