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
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 { 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 { 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 { 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; } } } #[cfg(test)] mod tests { use ::range; #[test] fn range() { let testvec = range::range(0, 4); println!("{:?}", testvec); } }