# Trait regex::Replacer [−] [src]

    pub trait Replacer {
        fn reg_replace(&mut self, caps: &Captures) -> Cow<str>;

        fn no_expand(&mut self) -> Option<Cow<str>> { ... }
    }

Replacer describes types that can be used to replace matches in a string.

## Required Methods

### `fn reg_replace(&mut self, caps: &Captures) -> Cow<str>`

Returns a possibly owned string that is used to replace the match corresponding to the `caps` capture group.

The `'a` lifetime refers to the lifetime of a borrowed string when a new owned string isn't needed (e.g., for `NoExpand`).

## Provided Methods

### `fn no_expand(&mut self) -> Option<Cow<str>>`

Returns a possibly owned string that never needs expansion.

## Implementors

- `impl<'t> Replacer for NoExpand<'t>`
- `impl<'t> Replacer for &'t str`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)