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
extern crate rand;
extern crate regex;
extern crate core;
pub mod parse;
pub mod boolean;
pub mod random;
pub mod sorting;
#[doc(hidden)] pub mod array;
#[doc(hidden)] pub mod string;
use std::fmt;
use std::fmt::{ Display, Formatter };
use std::error::Error;
pub enum RoundingMode { Trunc, Round, Ceil, Floor }
pub enum SortingAlgorithmn { Bubble, Quick }
#[derive(PartialEq, Debug)]
pub enum ParseError {
InvalidNumber(String),
InvalidString(String)
}
impl Error for ParseError{
fn description(&self) -> &'static str {
match self{
&ParseError::InvalidNumber(_) => "Invalid Number",
&ParseError::InvalidString(_) => "Invalid String"
}
}
fn cause(&self) -> Option<&Error> { None }
}
impl Display for ParseError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self{
&ParseError::InvalidNumber(ref i) => write!(f, "Invalid Number: {}", i),
&ParseError::InvalidString(ref i) => write!(f, "Invalid String: {}", i)
}
}
}
#[derive(PartialEq, Debug)]
pub enum ArithmeticError { DivideByZero }
impl Error for ArithmeticError {
fn description(&self) -> &'static str {
match self{
&ArithmeticError::DivideByZero => "DivideByZero"
}
}
fn cause(&self) -> Option<&Error> { None }
}
impl Display for ArithmeticError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self{
&ArithmeticError::DivideByZero => write!(f, "DivideByZero")
}
}
}
pub trait ArrayUtils<T> {
fn swaping(&mut self, a: usize, b: usize) -> bool;
fn shuffle(&mut self);
fn shuffle_seed(&mut self, seed: &[usize]);
fn index_of(&self, search: &T) -> usize;
}
pub trait StringUtils {
fn adv_contains_all_chars(&self, search: &[char])
-> (bool, Vec<usize>, Vec<char>);
fn adv_contains_all_strs(&self, search: &[&str])
-> (bool,Vec<usize>,Vec<String>);
fn adv_contains_any_char(&self, search: &[char]) -> (bool, usize, char);
fn adv_contains_any_str(&self, search: &[&str]) -> (bool, usize, String);
fn adv_contains_none_char(&self, search: &[char]) -> (bool, usize, char);
fn adv_contains_none_str(&self, search: &[&str]) -> (bool, usize, String);
fn adv_ends_with(&self, search: &str) -> (bool, String);
fn adv_starts_with(&self, search: &str) -> (bool, String);
fn contains_all_chars(&self, search: &[char]) -> bool;
fn contains_all_strs(&self, search: &[&str]) -> bool;
fn contains_any_char(&self, search: &[char]) -> bool;
fn contains_any_str(&self, search: &[&str]) -> bool;
fn contains_none_char(&self, search: &[char]) -> bool;
fn contains_none_str(&self, search: &[&str]) -> bool;
fn cmp_ignore_case(&self, cmp: &str) -> bool;
fn difference(&self, diff: &str) -> Vec<usize>;
fn find_char(&self, search: char) -> usize;
fn find_char_opt(&self, search: char) -> Option<usize>;
fn peek(&self) -> char;
fn peek_opt(&self) -> Option<char>;
fn remove_regex(&self, regex: &str) -> String;
fn remove_regex_mut(&mut self, regex: &str);
fn remove_all_regex(&self, regex: &str) -> String;
fn remove_all_regex_mut(&mut self, regex: &str);
fn reverse(&self) -> String;
fn reverse_mut(&mut self);
fn reverse_str(&self) -> &'static str;
}