pub struct EvilID(/* private fields */);Expand description
Simply stores a u64 and allows it to be exported in a human readable format.
Implementations§
Source§impl EvilID
impl EvilID
Sourcepub fn get(&self) -> String
pub fn get(&self) -> String
Get the id string.
Examples found in repository?
More examples
examples/stress_test.rs (line 9)
3fn main() {
4 let mut errors: u64 = 0;
5
6 for i in 1..=100000 {
7 let id = EvilID::generate();
8
9 let string = id.get();
10
11 let rebuilt_id = EvilID::new_from(string.clone());
12
13 match rebuilt_id {
14 Err(_) => {
15 errors += 1;
16 println!("Error rebuilding id {} on index {i}.", string.clone())
17 }
18 Ok(rebuilt_id) => {
19 if id != rebuilt_id {
20 println!("Rebuilt ID from {string} doesn't match original on index {i}.");
21 }
22 }
23 }
24 }
25
26 if errors == 0 {
27 println!("Test went with no errors whatsoever.");
28 } else {
29 println!("{errors} errors found!");
30 }
31}Sourcepub fn new_from(code: String) -> Result<Self, IllegalIDString>
pub fn new_from(code: String) -> Result<Self, IllegalIDString>
Get an id from an id string.
Any - are removed before proccesing the string.
Examples found in repository?
More examples
examples/stress_test.rs (line 11)
3fn main() {
4 let mut errors: u64 = 0;
5
6 for i in 1..=100000 {
7 let id = EvilID::generate();
8
9 let string = id.get();
10
11 let rebuilt_id = EvilID::new_from(string.clone());
12
13 match rebuilt_id {
14 Err(_) => {
15 errors += 1;
16 println!("Error rebuilding id {} on index {i}.", string.clone())
17 }
18 Ok(rebuilt_id) => {
19 if id != rebuilt_id {
20 println!("Rebuilt ID from {string} doesn't match original on index {i}.");
21 }
22 }
23 }
24 }
25
26 if errors == 0 {
27 println!("Test went with no errors whatsoever.");
28 } else {
29 println!("{errors} errors found!");
30 }
31}Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generate a new id.
Examples found in repository?
More examples
examples/stress_test.rs (line 7)
3fn main() {
4 let mut errors: u64 = 0;
5
6 for i in 1..=100000 {
7 let id = EvilID::generate();
8
9 let string = id.get();
10
11 let rebuilt_id = EvilID::new_from(string.clone());
12
13 match rebuilt_id {
14 Err(_) => {
15 errors += 1;
16 println!("Error rebuilding id {} on index {i}.", string.clone())
17 }
18 Ok(rebuilt_id) => {
19 if id != rebuilt_id {
20 println!("Rebuilt ID from {string} doesn't match original on index {i}.");
21 }
22 }
23 }
24 }
25
26 if errors == 0 {
27 println!("Test went with no errors whatsoever.");
28 } else {
29 println!("{errors} errors found!");
30 }
31}Trait Implementations§
impl Copy for EvilID
impl Eq for EvilID
impl StructuralPartialEq for EvilID
Auto Trait Implementations§
impl Freeze for EvilID
impl RefUnwindSafe for EvilID
impl Send for EvilID
impl Sync for EvilID
impl Unpin for EvilID
impl UnwindSafe for EvilID
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more