Crate bracoxide

Source
Expand description

This crate provides a powerful and intuitive way to perform string brace expansion. Brace expansion is a feature commonly found in shells and text processing tools, allowing you to generate all possible combinations of strings specified within curly braces.

§Features

  • Simple and Easy-to-Use: With the bracoxide crate, expanding brace patterns in strings becomes a breeze. Just pass in your input string, and the crate will generate all possible combinations for you.

  • Flexible Brace Expansion: The crate supports various brace expansion patterns, including numeric ranges ({0..9}), comma-separated options ({red,green,blue}), nested expansions ({a{b,c}d}, {x{1..3},y{4..6}}), and more.

  • Robust Error Handling: The crate provides detailed error handling, allowing you to catch and handle any issues that may arise during the tokenization and expansion process.

  • Lightweight and Fast: Designed to be efficient and performant, ensuring quick and reliable string expansion operations.

§Getting Started

To start using the bracoxide crate, add it as a dependency in your Cargo.toml:

[dependencies]
bracoxide = "0.1.2"
use bracoxide::explode;

fn main() {
    let content = "foo{1..3}bar";
    match explode(content) {
        Ok(expanded) => {
            // 1. `foo1bar`
            // 2. `foo2bar`
            // 3. `foo3bar`
            println!("Expanded patterns: {:?}", expanded);
        }
        Err(error) => {
            eprintln!("Error occurred: {:?}", error);
        }
    }
}

We hope you find the str expand crate to be a valuable tool in your Rust projects. Happy string expansion!

Modules§

parser
Provides functions and types for parsing tokens into an abstract syntax tree (AST).
tokenizer
Provides functionality for tokenizing input strings. It defines the Token enum, which represents individual tokens produced during tokenization, and the tokenize function, which converts an input string into a sequence of tokens.

Enums§

ExpansionError
An error type representing the failure to expand a parsed node.
OxidizationError
Errors that can occur during the Brace Expansion process.

Functions§

bracoxidize
Bracoxidize the provided content by tokenizing, parsing, and expanding brace patterns.
expand
Expands the given parsed node into a vector of strings representing the expanded values.
explode
Same functionality as bracoxidize but with explosive materials. This crates’ all Error types (except the OxidizationError) implements std::error::Error trait. Why not get all the benefits from it?