Expandable

Trait Expandable 

Source
pub trait Expandable {
    // Required method
    fn expand(&self, capture: &Captures<'_>) -> Self;
}
Expand description

Expanding regex captures in text objects.

Required Methods§

Source

fn expand(&self, capture: &Captures<'_>) -> Self

Returns self with the desired capture group expanded into self. For String, this is just a wrapper around Captures::expand.

§Example
use regex::Regex;
use stylish_stringlike::text::Expandable;
let re = Regex::new(r"(\d{3})[-. ,](\d{3})[-. ,](\d{4})").unwrap();
let captures = re.captures("555,123 4567").unwrap();
let target = String::from("($1) $2-$3");
assert_eq!(target.expand(&captures), String::from("(555) 123-4567"))

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Expandable for String

Source§

fn expand(&self, capture: &Captures<'_>) -> String

Implementors§

Source§

impl<'a, T: Clone> Expandable for Span<'a, T>

Source§

impl<T: Default + Clone + PartialEq> Expandable for Spans<T>