Struct grep_matcher::Match[][src]

pub struct Match { /* fields omitted */ }

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]);

Methods

impl Match
[src]

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

impl Clone for Match
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Match
[src]

impl Debug for Match
[src]

Formats the value using the given formatter. Read more

impl Eq for Match
[src]

impl Hash for Match
[src]

Feeds this value into the given [Hasher]. Read more

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

impl PartialEq for Match
[src]

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

This method tests for !=.

impl Index<Match> for [u8]
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl IndexMut<Match> for [u8]
[src]

Performs the mutable indexing (container[index]) operation.

impl Index<Match> for str
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

Auto Trait Implementations

impl Send for Match

impl Sync for Match