Skip to content

Commit aebee7c

Browse files
committed
feat: impl MatchSeqExt for &T and Option<T>
1 parent a1d933e commit aebee7c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/match_seq/match_seq_ext_impls.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,21 @@ impl<M, T> MatchSeqExt<SeqV<M, T>> for MatchSeq {
3737
}
3838
}
3939

40-
impl<M, T> MatchSeqExt<Option<&SeqV<M, T>>> for MatchSeq {
41-
fn match_seq(&self, sv: &Option<&SeqV<M, T>>) -> Result<(), ConflictSeq> {
42-
let seq = sv.map_or(0, |sv| sv.seq);
43-
self.match_seq(&seq)
40+
impl<T> MatchSeqExt<&T> for MatchSeq
41+
where MatchSeq: MatchSeqExt<T>
42+
{
43+
fn match_seq(&self, sv: &&T) -> Result<(), ConflictSeq> {
44+
self.match_seq(*sv)
4445
}
4546
}
4647

47-
impl<M, T> MatchSeqExt<Option<SeqV<M, T>>> for MatchSeq {
48-
fn match_seq(&self, sv: &Option<SeqV<M, T>>) -> Result<(), ConflictSeq> {
49-
self.match_seq(&sv.as_ref())
48+
impl<T> MatchSeqExt<Option<T>> for MatchSeq
49+
where MatchSeq: MatchSeqExt<T>
50+
{
51+
fn match_seq(&self, sv: &Option<T>) -> Result<(), ConflictSeq> {
52+
match sv {
53+
Some(sv) => self.match_seq(sv),
54+
None => MatchSeqExt::<u64>::match_seq(self, &0u64),
55+
}
5056
}
5157
}

0 commit comments

Comments
 (0)