Struct grep_matcher::Match[][src]

pub struct Match { /* fields omitted */ }
Expand description

The type of a match.

The type of a match is a possibly empty range pointing to a contiguous block of addressable memory.

Every Match is guaranteed to satisfy the invariant that start <= end.

Indexing

This type is structurally identical to std::ops::Range<usize>, but is a bit more ergonomic for dealing with match indices. In particular, this type implements Copy and provides methods for building new Match values based on old Match values. Finally, the invariant that start is always less than or equal to end is enforced.

A Match can be used to slice a &[u8], &mut [u8] or &str using range notation. e.g.,

use grep_matcher::Match;

let m = Match::new(2, 5);
let bytes = b"abcdefghi";
assert_eq!(b"cde", &bytes[m]);

Implementations

Create a new match.

Panics

This function panics if start > end.

Creates a zero width match at the given offset.

Return the start offset of this match.

Return the end offset of this match.

Return a new match with the start offset replaced with the given value.

Panics

This method panics if start > self.end.

Return a new match with the end offset replaced with the given value.

Panics

This method panics if self.start > end.

Offset this match by the given amount and return a new match.

This adds the given offset to the start and end of this match, and returns the resulting match.

Panics

This panics if adding the given amount to either the start or end offset would result in an overflow.

Returns the number of bytes in this match.

Returns true if and only if this match is empty.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.