strs_tools

Crates.iostrs_tools
lib.rsstrs_tools
version0.31.0
created_at2022-06-12 06:44:33.476186+00
updated_at2025-09-23 09:58:00.520041+00
descriptionTools to manipulate strings.
homepagehttps://github.com/Wandalen/wTools/tree/master/module/core/strs_tools
repositoryhttps://github.com/Wandalen/wTools/tree/master/module/core/strs_tools
max_upload_size
id604409
size651,010
Wandalen (Wandalen)

documentation

https://docs.rs/strs_tools

README

strs_tools

experimental rust-status docs.rs discord

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

cargo add strs_tools

Examples

Advanced String Splitting

Unlike 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"]
# }

Text Indentation

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  }"
# }

Command Parsing

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 finalized

Number Parsing

Robust 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 );
  }
}

Performance Features

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

Feature Selection

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 escaping
  • string_indentation - Text indentation tools
  • string_isolate - String isolation by delimiters
  • string_parse_request - Command parsing utilities
  • string_parse_number - Number parsing from strings
  • simd - 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 str methods for simple splitting and basic operations
  • Consider regex crate for complex pattern matching
  • Use clap or structopt for full CLI argument parsing frameworks

Examples

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

Documentation

Commit count: 998

cargo fmt