strs_tools
Advanced string manipulation tools with SIMD acceleration and intelligent parsing.
Why strs_tools?
While Rust's standard library provides basic string operations, strs_tools offers sophisticated string manipulation capabilities that handle real-world complexity:
- Smart Splitting: Split strings with quote awareness, escape handling, and delimiter preservation
- Intelligent Parsing: Parse command-like strings and extract key-value parameters
- Fast Performance: Optional SIMD acceleration for high-throughput text processing
- Memory Efficient: Zero-allocation operations where possible using
Cow<str>
Quick Start
Examples
Advanced String Splitting
Unlike standard str.split(), handles quotes and preserves context:
use string;
// Basic splitting with delimiter preservation
let text = "hello world test";
let result : = split
.src
.delimeter
.stripping // Keep delimiters
.perform
.map
.collect;
assert_eq!;
// Quote-aware splitting (perfect for parsing commands)
let command = r#"run --file "my file.txt" --verbose"#;
let parts : = split
.src
.delimeter
.quoting // Handle quotes intelligently
.perform
.map
.collect;
// Results: ["run", "--file", "my file.txt", "--verbose"]
Text Indentation
Add consistent indentation to multi-line text:
use string;
let code = "fn main() {\n println!(\"Hello\");\n}";
let indented = indentation;
// Result: " fn main() {\n println!(\"Hello\");\n }"
Command Parsing
Parse command-line style strings into structured data:
use string;
let input = "deploy --env production --force --config ./deploy.toml";
let parsed = parse;
// Extracts: subject="deploy", parameters={"env": "production", "force": "", "config": "./deploy.toml"}
Number Parsing
Robust number parsing with multiple format support:
use string;
let values = ;
for val in values
Performance Features
Enable SIMD acceleration for demanding applications:
[]
= { = "0.24", = ["simd"] }
SIMD features provide significant speedups for:
- Large text processing
- Pattern matching across multiple delimiters
- Bulk string operations
Feature Selection
Choose only the functionality you need:
[]
= {
version = "0.24",
= ["string_split", "string_parse_request"],
= false
}
Available features:
string_split- Advanced splitting with quotes and escapingstring_indentation- Text indentation toolsstring_isolate- String isolation by delimitersstring_parse_request- Command parsing utilitiesstring_parse_number- Number parsing from stringssimd- SIMD acceleration (recommended for performance)
When to Use strs_tools
Perfect for:
- CLI applications parsing complex commands
- Configuration file processors
- Text processing tools and parsers
- Data extraction from formatted text
- Applications requiring high-performance string operations
Alternatives:
- Use standard
strmethods for simple splitting and basic operations - Consider
regexcrate for complex pattern matching - Use
claporstructoptfor full CLI argument parsing frameworks
Examples
Explore comprehensive examples showing real-world usage:
# Run examples by number