1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use thiserror::Error;
use std::num::ParseIntError;
#[derive(Clone, Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("Invalid diff: {0}")]
BadDiff(&'static str),
#[error("Diff didn't apply to input: {0}")]
CantApply(&'static str),
}
impl From<ParseIntError> for Error {
fn from(_e: ParseIntError) -> Error {
Error::BadDiff("can't parse line number")
}
}
impl From<hex::FromHexError> for Error {
fn from(_e: hex::FromHexError) -> Error {
Error::BadDiff("invalid hexadecimal in 'hash' line")
}
}