Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jumperbot/whitespace-sifter
Sift duplicate whitespaces away!
https://github.com/jumperbot/whitespace-sifter
dedup deduplicator rust rust-crate rust-lang rust-language rust-library sift string string-formatting string-manipulation text whitespace-removal
Last synced: 3 months ago
JSON representation
Sift duplicate whitespaces away!
- Host: GitHub
- URL: https://github.com/jumperbot/whitespace-sifter
- Owner: JumperBot
- License: mit
- Created: 2022-12-26T12:35:54.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-15T12:09:08.000Z (6 months ago)
- Last Synced: 2024-10-12T15:21:31.237Z (3 months ago)
- Topics: dedup, deduplicator, rust, rust-crate, rust-lang, rust-language, rust-library, sift, string, string-formatting, string-manipulation, text, whitespace-removal
- Language: Rust
- Homepage: https://crates.io/crates/whitespace-sifter
- Size: 2.62 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# whitespace-sifter
![crates.io version](https://img.shields.io/crates/v/whitespace-sifter.svg?label=release)
![github.com forks](https://img.shields.io/github/forks/JumperBot/whitespace-sifter)
![github.com stars](https://img.shields.io/github/stars/JumperBot/whitespace-sifter)
![crates.io downloads](https://img.shields.io/crates/d/whitespace-sifter.svg?label=downloads)---
```rust
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(),
);
```---
## ✨ Sift Duplicate Whitespaces In One Function Call
This crate **helps you** remove duplicate [whitespaces](https://doc.rust-lang.org/reference/whitespace.html) within a `string`.
It naturally removes the whitespaces at the start and end of the `string`.---
## ⚡️Benchmarks
Performance is a priority; Most updates are performance improvements.
The benchmark uses a transcript of the [Bee Movie](https://movies.fandom.com/wiki/Bee_Movie/Transcript).Execute these commands to benchmark:
```bash
$ 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:
```bash
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?
Go try it on a better machine, I guess.
Benchmark specifications:
- Processor: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz 1.90 GHz
- Memory: RAM 16.0 GB (15.8 GB usable)
- System: GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64
---
## 📄 Licensing
`whitespace-sifter` is licensed under the [`MIT LICENSE`](./LICENSE); This is the [`summarization`](https://choosealicense.com/licenses/mit/).