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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
extern crate serde; #[macro_use] extern crate serde_derive; pub mod disp { use std::fmt; pub fn print<T>(text: T) where T: fmt::Display { println!("{}", text); return; } pub fn newline() { println!(""); return; } pub fn print_debug<T>(data: T) where T: fmt::Debug { println!("{:?}", data); return; } } pub mod range { pub fn range(x: u32, y: u32) -> Vec<u32> { let mut iterator = x; let mut list = Vec::new(); list.push(iterator); while iterator != y { iterator += 1; list.push(iterator); } return list; } } pub mod arg { use std::env; pub fn get_args() -> Vec<String> { let args = env::args().collect(); return args; } } pub mod conv { use std::string::String; pub fn b_str(str: &str) -> String { let no_borrow: String = str.to_string(); return no_borrow; } } pub mod stringutil { pub fn get_char_pos(string: String, char_loc: usize) -> char { let char_vec: Vec<char> = string.chars().collect(); return char_vec[char_loc]; } } pub mod appinfo { #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct AppInfo { pub name: &'static str, pub author: &'static str, pub repository: &'static str, pub crate_link: &'static str, } impl AppInfo { pub fn new() -> AppInfo { let appinfo: AppInfo = AppInfo {name: "", author: "", repository: "", crate_link: ""}; return appinfo; } } } pub mod point { #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct Point { pub x: i32, pub y: i32, } impl Point { pub fn new() -> Point { let point: Point = Point {x: 0, y: 0}; return point; } } } pub mod coordinate { #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct Coordinate { pub x: i32, pub y: i32, pub z: i32, } impl Coordinate { pub fn new() -> Coordinate { let coordinate: Coordinate = Coordinate {x: 0, y: 0, z: 0}; return coordinate; } } } pub mod shape { pub mod quadrilateral { use point::Point; #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct Quadrilateral { pub corner: [Point; 4], } impl Quadrilateral { pub fn new() -> Quadrilateral { let quadrilateral: Quadrilateral = Quadrilateral {corner: [Point {x: 0, y: 0}; 4]}; return quadrilateral; } } } pub mod hexahedron { use coordinate::Coordinate; #[derive(Serialize, Deserialize, Debug, Clone, Copy)] pub struct Hexahedron { pub corner: [Coordinate; 8], } impl Hexahedron { pub fn new() -> Hexahedron { let hexahedron: Hexahedron = Hexahedron {corner: [Coordinate {x: 0, y: 0, z: 0}; 8]}; return hexahedron; } } } } #[cfg(test)] mod tests { use ::range; #[test] fn range() { let testvec = range::range(0, 4); println!("{:?}", testvec); } }