1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TagPosition {
pub tag_position: String,
pub tag_value: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EdgeValue {
pub is_open: bool,
pub edge_tag: Vec<TagPosition>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Edge {
pub tile_edge: EdgeValue,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Tile {
pub tile_id: String,
pub tile_center: String,
pub tile_edges: Vec<Edge>,
}
pub fn identify_tile(tile: &mut Tile) -> Result<Tile, Box<dyn std::error::Error>> {
let mut id_vec: Vec<char> = Vec::new();
let char_1: char = tile
.tile_center
.chars()
.into_iter()
.next()
.expect("string's empty...");
id_vec.push(char_1);
for edge in tile.tile_edges.iter() {
let is_open_bit: char = if edge.tile_edge.is_open == false {
'0'
} else {
'1'
};
id_vec.push(is_open_bit);
for tag_position in edge.tile_edge.edge_tag.iter() {
for tag_value_char in tag_position.tag_value.chars() {
id_vec.push(tag_value_char);
}
}
}
let tile_id_string: String = id_vec.into_iter().collect();
tile.tile_id = tile_id_string;
Ok(tile.clone())
}
pub mod generate {
use std::io::{stdin,stdout,Write};
pub fn custom_polygon() {
let mut side_input: String = String::new();
println!("number of sides:");
stdin().read_line(&mut side_input).expect("nope. bad string. don't like it.");
}
}