8 releases (4 breaking)
Uses new Rust 2024
0.7.9 | Feb 23, 2025 |
---|---|
0.7.8 | Feb 23, 2025 |
0.6.6 | Feb 22, 2025 |
0.5.6 | Feb 22, 2025 |
0.3.5 | Feb 16, 2025 |
#56 in No standard library
770 downloads per month
Used in 2 crates
82KB
1.5K
SLoC
Sew
Sew is a Rust library that provides a constant-size string with various manipulation methods, along with other unique string types. It is designed to be used in no_std
environments and offers features like serialization, random string generation, and more.
Features
- Constant-Size Strings:
ConStr
is a fixed-size character string structure that allows for efficient manipulation and querying. - Infallible Strings:
InfallibleString
can represent both valid and invalid UTF-8 sequences, useful for handling arbitrary byte sequences. - Pattern Searching: Implement custom pattern searching with the
PatternSearcher
trait, and more advanced modifications with theGetChar
andGetSubStr
traits. - Macros: Easily create
ConStr
instances with thenew_cstr!
macro. - Feature Flags:
serde
: Enables serialization and deserialization support.rand
: Allows for random string generation.expandable
: Additional utilities for string manipulation.unsafe_infallible
: Provides unsafe mutable access toInfallibleString
via DerefMut.
Installation
Add sew
to your Cargo.toml
:
[dependencies]
sew = { version = "0.7.7", features = ["full_unsafe"] }
Usage
Basic Usage
use sew::helpers::new_cstr;
fn main() {
let x = new_cstr!("Hello, World!");
println!("{}", x);
}
Features
Constant-Size Strings
ConStr
provides a variety of methods for string manipulation:
new()
: Create a newConStr
initialized with NUL characters.len()
: Get the length of theConStr
.insert()
,remove()
,replace()
: Modify the string content.to_uppercase()
,to_lowercase()
: Change the case of the string.
Infallible Strings
InfallibleString
can handle both valid and invalid UTF-8 sequences:
new_valid()
: Create a validInfallibleString
.new_invalid()
: Create an invalidInfallibleString
.push_str()
,push_byte()
: Append content to the string.
Pattern Searching
Implement the PatternSearcher
trait to define custom pattern matching logic, or GetChar
or GetSubStr
for advanced modification logic.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is dual licensed under the MIT and Apache 2.0 Licenses.
Dependencies
~0–370KB