Add library and documents

This commit is contained in:
2025-08-10 15:11:24 +08:00
parent 808c5acd2b
commit f602ddb4b5
23 changed files with 584 additions and 41 deletions

View File

@@ -1,12 +1,15 @@
//!Extensions for fancy_regex crate.
use anyhow::Result;
use fancy_regex::Regex;
/// Extension trait for [fancy_regex::Regex] to provide more convenient methods.
pub trait FancyRegexExt {
/// Splits the input string by the regex pattern.
/// Like python's `re.split()`, but returns an iterator.
fn py_split<'a>(&'a self, input: &'a str) -> Result<PySplit<'a>>;
}
/// An iterator that splits a string by a regex pattern, similar to Python's `re.split()`.
pub struct PySplit<'a> {
str: &'a str,
pos: Vec<(usize, usize)>,