Trait stylish_stringlike::text::Expandable[][src]

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

Expanding regex captures in text objects.

Required methods

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

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"))

Implementations on Foreign Types

impl Expandable for String[src]

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

Implementors

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

fn expand(&self, capture: &Captures<'_>) -> Span<'a, T>[src]

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

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