Struct Captures

Source
pub struct Captures<'t, I> { /* private fields */ }
Expand description

Captures represents a group of captured sub-slice for a single match.

The 0th capture always corresponds to the entire match. Each subsequent index corresponds to the next capture group in the regex. If a capture group is named, then the matched sub-slice is also available via the name method. (Note that the 0th capture is always unnamed and so must be accessed with the get method.)

't is the lifetime of the matched slice.

Implementations§

Source§

impl<'t, I> Captures<'t, I>

Source

pub fn get(&self, index: usize) -> Option<Match<'t, I>>

Returns the match associated with the capture group at index i. If i does not correspond to a capture group, or if the capture group did not participate in the match, then None is returned.

Source

pub fn name(&self, name: &str) -> Option<Match<'t, I>>

Returns the match for the capture group named name. If name isn’t a valid capture group or didn’t match anything, then None is returned.

Source

pub fn len(&self) -> usize

Returns the total number of capture groups (even if they didn’t match). This is always at least 1, since every regex has at least one capture group that corresponds to the full match.

Trait Implementations§

Source§

impl<'t, I: Debug> Debug for Captures<'t, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t, I> Freeze for Captures<'t, I>

§

impl<'t, I> RefUnwindSafe for Captures<'t, I>
where I: RefUnwindSafe,

§

impl<'t, I> !Send for Captures<'t, I>

§

impl<'t, I> !Sync for Captures<'t, I>

§

impl<'t, I> Unpin for Captures<'t, I>

§

impl<'t, I> UnwindSafe for Captures<'t, I>
where I: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.