bmatcher_core/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use core::{fmt::Debug, ops::Range};

/// A PositionedError representing an error that is associated with a specific position in the given pattern.
#[derive(Debug, PartialEq)]
pub struct PositionedError<E: Debug + PartialEq> {
    position: Range<usize>,
    inner: E,
}

impl<E: Debug + PartialEq> PositionedError<E> {
    pub fn new(position: Range<usize>, inner: E) -> Self {
        Self { position, inner }
    }

    pub fn position(&self) -> &Range<usize> {
        &self.position
    }

    pub fn inner(&self) -> &E {
        &self.inner
    }
}