1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*!
# Trimothy
[](https://docs.rs/trimothy/)
[](https://github.com/Blobfolio/trimothy/blob/master/CHANGELOG.md)<br>
[](https://crates.io/crates/trimothy)
[](https://github.com/Blobfolio/trimothy/actions)
[](https://deps.rs/crate/trimothy/)<br>
[](https://en.wikipedia.org/wiki/WTFPL)
[](https://github.com/Blobfolio/trimothy/issues)
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.
### [`TrimSliceMatches`]
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`
### [`TrimMut`]
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). |
### [`TrimMatchesMut`]
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:
* A single T;
* An array or slice of T;
* A `&BtreeSet<T>`
* A custom callback with signature `Fn(T) -> bool`
Where T is `char` for string sources, and `u8` for byte sources.
### [`TrimNormal`]
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.
*/
extern crate alloc;
pub use ;
pub use ;
pub use TrimSliceMatches;