immutable_json/error.rs
1use std::fmt;
2
3#[derive(Debug)]
4pub struct JsonIndexError {
5 pub index: usize,
6 pub len: usize,
7}
8
9impl fmt::Display for JsonIndexError {
10 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11 write!(
12 f,
13 "the index {} is higher than {}",
14 self.index,
15 self.len - 1
16 )
17 }
18}
19
20impl PartialEq for JsonIndexError {
21 fn eq(&self, other: &Self) -> bool {
22 self.index == other.index && self.len == other.len
23 }
24}