[−][src]Crate rustils
Usage
This crate is on crates.io and can be
used by adding rustils
to your dependencies in your project's Cargo.toml
.
[dependencies]
rustils = "0.1.23"
and this to your crate root:
extern crate rustils;
Examples
use rustils::parse::byte::ToI8; use rustils::error::ParseError::InvalidNumber; let a = -128_i32; let b = 127_i32; let c = -129_i32; let d = 128_i32; //Rust assert_eq!(a as i8, -128_i8); assert_eq!(b as i8, 127_i8); assert_eq!(c as i8, 127_i8); assert_eq!(d as i8, -128_i8); //rustils assert_eq!(a.to_i8(), -128_i8); assert_eq!(b.to_i8(), 127_i8); assert_eq!(c.to_i8_res(), Err(InvalidNumber("-129".to_string()))); assert_eq!(d.to_i8_res(), Err(InvalidNumber("128".to_string())));
use rustils::string::StringUtils; let text = "你好。How are you?"; //Rust function assert_eq!(text.find('好'), Some(3)); //rustils functions assert_eq!(text.find_char_opt('好'), Some(1)); assert_eq!(text.find_char('好'), 1);
use rustils::string::StringUtils; let text1 = &mut String::from("你好。How are you?"); //Rust function assert_eq!(text1.remove(3), '好'); assert_eq!(text1, "你。How are you?"); let text3 = String::from("你好。How are you?"); let text4 = &mut String::from("你好。How are you?"); let regex = r"[aeiou]+|[好]+"; //rustils functions assert_eq!(text3.remove_regex(regex), String::from("你。How are you?")); assert_eq!(text3.remove_all_regex(regex), String::from("你。Hw r y?")); assert_eq!(true, text4.remove_regex_mut(regex)); assert_eq!(text4, "你。How are you?"); assert_eq!(true, text4.remove_all_regex_mut(regex)); assert_eq!(text4, "你。Hw r y?");
Modules
array | Array manipulation |
error | |
parse | Parsing primitives to others |
random | |
sorting | |
string | String manipulation |
Macros
and | |
or | |
xor |
Enums
RoundingMode |