Advanced string manipulation tools with SIMD acceleration and intelligent parsing.
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>
cargo add strs_toolsUnlike standard str.split(), handles quotes and preserves context:
# #[cfg(all(feature = "string_split", not(feature = "no_std")))]
# {
use strs_tools::string;
// Basic splitting with delimiter preservation
let text = "hello world test";
let result : Vec< String > = string::split()
.src( text )
.delimiter( " " )
.preserving_delimiters( true ) // Keep delimiters
.perform()
.map( String::from )
.collect();
assert_eq!( result, vec![ "hello", " ", "world", " ", "test" ] );
// Quote-aware splitting (perfect for parsing commands)
let command = r#"run --file "my file.txt" --verbose"#;
let parts : Vec< String > = string::split()
.src( command )
.delimiter( " " )
.quoting( true ) // Handle quotes intelligently
.perform()
.map( String::from )
.collect();
// Results: ["run", "--file", "my file.txt", "--verbose"]
# }Add consistent indentation to multi-line text:
# #[cfg(all(feature = "string_indentation", not(feature = "no_std")))]
# {
use strs_tools::string;
let code = "fn main() {\n println!(\"Hello\");\n}";
let indented = string::indentation::indentation( " ", code, "" );
// Result: " fn main() {\n println!(\"Hello\");\n }"
# }Parse command-line style strings into structured data:
use strs_tools::string;
let input = "deploy --env production --force --config ./deploy.toml";
// Command parsing functionality under development
println!( "Command: {}", input );
// Note: Full parse_request API is still being finalizedRobust number parsing with multiple format support:
let values = [ "42", "3.14", "1e6" ];
for val in values
{
if let Ok( num ) = val.parse::< f64 >()
{
println!( "{} = {}", val, num );
}
}Enable SIMD acceleration for demanding applications:
[dependencies]
strs_tools = { version = "0.30", features = ["simd"] }SIMD features provide significant speedups for:
- Large text processing
- Pattern matching across multiple delimiters
- Bulk string operations
Choose only the functionality you need:
[dependencies]
strs_tools = {
version = "0.30",
features = ["string_split", "string_parse_request"],
default-features = 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)
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
Explore comprehensive examples showing real-world usage:
git clone https://github.com/Wandalen/wTools
cd wTools/module/core/strs_tools
# Run examples by number
cargo run --example 001_basic_usage
cargo run --example 002_advanced_splitting
cargo run --example 003_text_indentation
cargo run --example 004_command_parsing
cargo run --example 005_string_isolation
cargo run --example 006_number_parsing
cargo run --example 007_performance_and_simd --features simd