Crates.io | whitespace-sifter |
lib.rs | whitespace-sifter |
version | 2.3.0 |
source | src |
created_at | 2022-12-26 12:53:43.516421 |
updated_at | 2024-07-15 11:34:50.277089 |
description | Sift duplicate whitespaces away! |
homepage | |
repository | https://github.com/JumperBot/whitespace-sifter/ |
max_upload_size | |
id | 745757 |
size | 81,637 |
use whitespace_sifter::WhitespaceSifter;
// This prints `1.. 2.. 3.. 4.. 5..`.
println!(
"{}",
"1.. \n2.. \n\r\n\n3.. \n\n\n4.. \n\n\r\n\n\n5.. \n\n\n\n\n".sift(),
);
// This prints `1..\n2..\n3..\n4..\r\n5..`.
println!(
"{}",
"1.. \n2.. \n\r\n3.. \n\n\n4.. \r\n\n\r\n\n5.. \n\n\n\n\n"
.sift_preserve_newlines(),
);
This crate helps you remove duplicate whitespaces within a string
.
It naturally removes the whitespaces at the start and end of the string
.
Performance is a priority; Most updates are performance improvements.
The benchmark uses a transcript of the Bee Movie.
Execute these commands to benchmark:
$ git clone https://github.com/JumperBot/whitespace-sifter.git
$ cd whitespace-sifter
$ cargo bench
You should only look for results that look like the following:
Sift/Sift time: [159.31 µs 159.60 µs 159.95 µs]
Sift Preserved/Sift Preserved
time: [198.11 µs 198.21 µs 198.32 µs]
In just 0.0001 seconds; Pretty impressive, no?
whitespace-sifter
is licensed under the MIT LICENSE
; This is the summarization
.