Expand description
No more relying solely on the standard library’s String! CheetahString is a versatile string type that can store static and dynamic strings.
It is usable in both std and no_std environments. Additionally, CheetahString supports serde for serialization and deserialization.
The bytes feature exposes CheetahBytes for byte-oriented data.
It minimizes allocations across small, shared, and builder-oriented string workloads.
Substring search uses memchr/memmem by default.
§SIMD Acceleration
When compiled with the simd feature flag, CheetahString uses SIMD (Single Instruction, Multiple Data)
instructions to accelerate selected byte comparisons on x86_64 platforms with SSE2 support.
SIMD acceleration is applied to:
starts_with()- Pattern prefix matchingends_with()- Pattern suffix matching- Equality comparisons (
==,!=)
The implementation automatically uses SIMD for strings >= 16 bytes and falls back to scalar operations for smaller inputs or when SIMD is not available.
To enable SIMD acceleration:
[dependencies]
cheetah-string = { version = "1.1.0", features = ["simd"] } §Examples
Basic usage:
use cheetah_string::CheetahString;
let s = CheetahString::from("Hello, world!");
let s2:&'static str = "Hello, world!";
let s3 = CheetahString::from_static_str(s2);
let s4 = CheetahString::new();
Using accelerated search operations:
use cheetah_string::CheetahString;
let url = CheetahString::from("https://api.example.com/v1/users");
// Substring search uses memchr/memmem by default.
if url.starts_with("https://") {
println!("Secure connection");
}
if url.contains("api") {
println!("API endpoint");
}Structs§
- Cheetah
Finder - Reusable substring finder for repeated searches with the same needle.
- Cheetah
String - Split
Str - Helper struct for splitting strings by a string pattern
Enums§
- Error
- Errors that can occur during CheetahString operations
- Split
Wrapper - Wrapper for split iterator that supports both char and str patterns
Traits§
- Split
Pattern - A pattern that can be used with
splitmethod. - StrPattern
- A pattern that can be used with
starts_withandends_withmethods.
Type Aliases§
- Result
- Result type for CheetahString operations