Skip to content

Commit

Permalink
add support for comparing BaseEncoded with different BaseEncoders
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Huseby <[email protected]>
  • Loading branch information
dhuseby committed May 10, 2024
1 parent c7a4951 commit bc3ec15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multiutil"
version = "1.0.5"
version = "1.0.6"
edition = "2021"
authors = ["Dave Huseby <[email protected]>"]
description = "Multiformat utility functions and types"
Expand Down
10 changes: 6 additions & 4 deletions src/base_encoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,24 @@ where
}
}

impl<T, Enc> PartialEq for BaseEncoded<T, Enc>
impl<T, Enc, OtherEnc> PartialEq<BaseEncoded<T, OtherEnc>> for BaseEncoded<T, Enc>
where
T: EncodingInfo + PartialEq<T> + ?Sized,
Enc: BaseEncoder,
OtherEnc: BaseEncoder,
{
fn eq(&self, other: &Self) -> bool {
fn eq(&self, other: &BaseEncoded<T, OtherEnc>) -> bool {
self.base == other.base && self.t == other.t
}
}

impl<T, Enc> PartialOrd for BaseEncoded<T, Enc>
impl<T, Enc, OtherEnc> PartialOrd<BaseEncoded<T, OtherEnc>> for BaseEncoded<T, Enc>
where
T: EncodingInfo + PartialEq<T> + PartialOrd<T> + ?Sized,
Enc: BaseEncoder,
OtherEnc: BaseEncoder,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
fn partial_cmp(&self, other: &BaseEncoded<T, OtherEnc>) -> Option<Ordering> {
self.t.partial_cmp(&other.t)
}
}
Expand Down

0 comments on commit bc3ec15

Please sign in to comment.