Skip to content

Commit 52a74e7

Browse files
committed
some instances for ParseError
1 parent 1d85f8d commit 52a74e7

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

rust/functora-tagged/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/functora-tagged/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ serde = ["dep:serde"]
2222
[dev-dependencies]
2323
diesel = { version = "2.3.3", features = ["sqlite"] }
2424
libsqlite3-sys = { version = "0.35.0", features = ["bundled"] }
25+
num-traits = "0.2.19"
2526
serde = { version = "1.0.228", features = ["derive"] }
2627
toml = "0.9.8"

rust/functora-tagged/src/lib.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,56 @@ where
6868
Refine(Tag::RefineError),
6969
}
7070

71+
impl<Rep, Tag> Eq for ParseError<Rep, Tag>
72+
where
73+
Rep: FromStr,
74+
Tag: Refine<Rep>,
75+
Rep::Err: Eq,
76+
Tag::RefineError: Eq,
77+
{
78+
}
79+
80+
impl<Rep, Tag> PartialEq for ParseError<Rep, Tag>
81+
where
82+
Rep: FromStr,
83+
Tag: Refine<Rep>,
84+
Rep::Err: PartialEq,
85+
Tag::RefineError: PartialEq,
86+
{
87+
fn eq(&self, other: &Self) -> bool {
88+
match (self, other) {
89+
(
90+
ParseError::Decode(a),
91+
ParseError::Decode(b),
92+
) => a == b,
93+
(
94+
ParseError::Refine(a),
95+
ParseError::Refine(b),
96+
) => a == b,
97+
_ => false,
98+
}
99+
}
100+
}
101+
102+
impl<Rep, Tag> Clone for ParseError<Rep, Tag>
103+
where
104+
Rep: FromStr,
105+
Tag: Refine<Rep>,
106+
Rep::Err: Clone,
107+
Tag::RefineError: Clone,
108+
{
109+
fn clone(&self) -> Self {
110+
match self {
111+
ParseError::Decode(err) => {
112+
ParseError::Decode(err.clone())
113+
}
114+
ParseError::Refine(err) => {
115+
ParseError::Refine(err.clone())
116+
}
117+
}
118+
}
119+
}
120+
71121
impl<Rep, Tag> FromStr for Tagged<Rep, Tag>
72122
where
73123
Rep: FromStr,

0 commit comments

Comments
 (0)