Skip to content

Commit

Permalink
Implement PartialOrd and Ord for Text
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed May 14, 2024
1 parent 8ade009 commit 9d07721
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/biome_deserialize/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ impl Text {
self.0.text()
}
}

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

impl Ord for Text {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.text().cmp(other.text())
}
}

#[cfg(feature = "serde")]
impl serde::Serialize for Text {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.0.text().serialize(serializer)
}
}

impl Deref for Text {
type Target = str;
fn deref(&self) -> &Self::Target {
Expand Down

0 comments on commit 9d07721

Please sign in to comment.