Skip to content

Commit

Permalink
[ISSUE #19]Implement PartialEq,Eq,PartialOrd,Ord for CheetahString (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm authored Nov 7, 2024
1 parent 9934a66 commit b72bfe7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cheetah_string.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::Ordering;
use std::ops::Deref;
use std::sync::Arc;

Expand Down Expand Up @@ -172,6 +173,26 @@ impl CheetahString {
}
}

impl PartialEq for CheetahString {
fn eq(&self, other: &Self) -> bool {
self.as_str() == other.as_str()
}
}

impl Eq for CheetahString {}

impl PartialOrd for CheetahString {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for CheetahString {
fn cmp(&self, other: &Self) -> Ordering {
self.as_str().cmp(other.as_str())
}
}

/// The `InnerString` enum represents different types of string storage.
///
/// Variants:
Expand Down

0 comments on commit b72bfe7

Please sign in to comment.