#std #re-exports #missing

knarkzel

Useful functions and re-exports missing in std

7 releases (breaking)

0.6.0 Mar 28, 2021
0.5.0 Mar 26, 2021
0.4.1 Mar 26, 2021
0.3.0 Mar 13, 2021
0.1.0 Mar 13, 2021

#31 in #re-exports

GPL-2.0 license

5KB
60 lines

Filesystem

The slurp function can be used for reading a file.

let columns = slurp("mock.csv")?;

Regex

let text = "Not my favorite movie: 'Citizen Kane' (1941).";
let regex = Regex::new(r"'([^']+)'\s+\((\d{4})\)")?;
let captures = regex.captures(text)?;

assert_eq!(&captures[0], "'Citizen Kane' (1941)");
assert_eq!(&captures[1], "Citizen Kane");
assert_eq!(&captures[2], "1941");

Random

let mut random = Random::new().with_seed(1234);
let unsigned = random.rand_u64();
let signed = random.rand_i64();
let float = random.rand_float();
let range = random.rand_range(1..100);
let float_range = random.rand_range_float(-5.0..5.0);

Itertools

let items = vec![1, 2, 3];
let data = items
.iter()
.map(|x| x * 3)
.collect_vec();

Dependencies

~2.6–4MB
~66K SLoC