Skip to content

Commit aadd000

Browse files
committed
Impl PartialOrd and Ord for Invoice
1 parent 818dbdf commit aadd000

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@ pub struct Invoice {
253253
signed_invoice: SignedRawInvoice,
254254
}
255255

256+
impl PartialOrd for Invoice {
257+
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
258+
self.to_string().partial_cmp(&other.to_string())
259+
}
260+
}
261+
262+
impl Ord for Invoice {
263+
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
264+
self.to_string().cmp(&other.to_string())
265+
}
266+
}
267+
256268
/// Represents the description of an invoice which has to be either a directly included string or
257269
/// a hash of a description provided out of band.
258270
///

0 commit comments

Comments
 (0)