Implementing methods / utilities for rust primitive types
Please keep in mind that I am not a rust wizard and this methods may not be blazingly fast or may not follow the best practices
Installation
Add this to your Cargo.toml
[]
# if you want methods for a specific type then add them as a feature
= { = "0.1.0", = ["strings", "bool"] }
# if you want all methods available for all types then add
= { = "0.1.1", = ["all_types"] }
# features currently available:
# strings, bool, vec, "result", "option"
And bring the traits to scope like this:
use *;
Types
Strings
so far, for strings String
and &str
I have implemented:
string.first()
Examples
use crate SelectNth;
let case1 = String from;
assert_eq!;
let case2 = String from;
assert_eq!;
string.remove_whitespaces()
Examples
use crate RemoveWhitespaces;
let case1 = String from;
assert_eq!;
let case2 = String from;
assert_eq!;
string.to_snake_case()
Examples
use crate ToCases;
let case1 = String from;
assert_eq!;
let case2 = String from;
assert_eq!;
string.to_camel_case()
Examples
use crate ToCases;
let case1 = String from;
assert_eq!;
let case2 = String from;
assert_eq!;
let case3 = String from;
assert_eq!;
string.to_pascal_case()
Examples
use crate ToCases;
let case1 = String from;
assert_eq!;
let case2 = String from;
assert_eq!;
let case3 = String from;
assert_eq!;
Bool
so far, for bool
I have implemented:
bool.toggle()
use crate*;
Result
so far, for Result<T, E>
I have implemented:
result.filter()
Examples
use crate Filter;
let case1 = "2".;
let case1 = case1.filter;
assert_eq!;
let case2 = "err".;
let case2 = case2.filter;
match case2 ;
let case3 = "10".;
let case3 = case3.filter;
match case3 ;
Vec
so far, for Vec<T> where T: PartialEq + Clone
I have implemented:
Option
so far, for Option<T>
I have implemented:
option.is_none_and()
Examples
use crate IsNone;
let case1 = Some;
assert!;
let case2 : = None;
assert!;