Crates.io | trimothy |
lib.rs | trimothy |
version | |
source | src |
created_at | 2022-04-11 21:14:41.932614 |
updated_at | 2024-11-28 19:07:00.005656 |
description | Traits for trimming slices, vecs, and strings. |
homepage | |
repository | https://github.com/Blobfolio/trimothy |
max_upload_size | |
id | 566100 |
Cargo.toml error: | TOML parse error at line 26, column 1 | 26 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Trimothy is a small library that expands on the limited String- and slice-trimming capabilities provided by the standard library.
If any of these methods happened to be introduced into stable Rust in the future, they will simply be removed from here.
This crate is #![no_std]
-compatible.
This trait adds the arbitrary, match-based trimming methods to &[u8]
, Vec<u8>
, and Box<[u8]>
:
Method | Description |
---|---|
trim_matches |
Trim arbitrary leading and trailing bytes. |
trim_start_matches |
Trim arbitrary leading bytes. |
trim_end_matches |
Trim arbitrary trailing bytes. |
Each of these match methods accept either:
A single u8
;
An array or slice of u8
;
A &BtreeSet<u8>
A custom callback with signature Fn(u8) -> bool
This trait brings mutable trimming support to String
, Vec<u8>
, and Box<[u8]>
.
Method | Description |
---|---|
trim_mut |
Trim leading and trailing whitespace (mutably). |
trim_start_mut |
Trim leading whitespace (mutably). |
trim_end_mut |
Trim trailing whitespace (mutably). |
This trait brings mutable match-based trimming String
, Vec<u8>
, and Box<[u8]>
.
Method | Description |
---|---|
trim_matches_mut |
Trim arbitrary leading and trailing bytes (mutably). |
trim_start_matches_mut |
Trim arbitrary leading bytes (mutably). |
trim_end_matches_mut |
Trim arbitrary trailing bytes (mutably). |
Each of these match methods accept either:
&BtreeSet<T>
Fn(T) -> bool
Where T is char
for string sources, and u8
for byte sources.
This trait adds a single trim_and_normalize
method to owned and borrowed string and byte slices that trims leading/trailing whitespace, and compacts/normalizes spans of inner whitespace to a single horizontal space.
Method | Description |
---|---|
trim_and_normalize |
Trim, normalize, and return. |
The TrimNormalBytes
and TrimNormalChars
traits can be used to extend
this same functionality to arbitrary iterators of u8
and char
,
respectively.
The dependency can be added the normal way:
[dependencies]
trimothy = "0.6"