mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
impl Eq/Ord for Lua String
This commit is contained in:
+27
-5
@@ -164,19 +164,25 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<String> for String {
|
||||
impl PartialEq for String {
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
self.as_bytes() == other.as_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<&String> for String {
|
||||
fn eq(&self, other: &&String) -> bool {
|
||||
self.as_bytes() == other.as_bytes()
|
||||
impl Eq for String {}
|
||||
|
||||
impl PartialOrd for String {
|
||||
fn partial_cmp(&self, other: &String) -> Option<cmp::Ordering> {
|
||||
self.as_bytes().partial_cmp(&other.as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for String {}
|
||||
impl Ord for String {
|
||||
fn cmp(&self, other: &String) -> cmp::Ordering {
|
||||
self.as_bytes().cmp(&other.as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for String {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
@@ -244,6 +250,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for BorrowedStr<'_> {}
|
||||
|
||||
impl<T> PartialOrd<T> for BorrowedStr<'_>
|
||||
where
|
||||
T: AsRef<str>,
|
||||
@@ -253,6 +261,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for BorrowedStr<'_> {
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
self.0.cmp(other.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// A borrowed byte slice (`&[u8]`) that holds a strong reference to the Lua state.
|
||||
pub struct BorrowedBytes<'a>(&'a [u8], #[allow(unused)] Lua);
|
||||
|
||||
@@ -294,6 +308,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for BorrowedBytes<'_> {}
|
||||
|
||||
impl<T> PartialOrd<T> for BorrowedBytes<'_>
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
@@ -303,6 +319,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for BorrowedBytes<'_> {
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
self.0.cmp(other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for BorrowedBytes<'a> {
|
||||
type Item = &'a u8;
|
||||
type IntoIter = slice::Iter<'a, u8>;
|
||||
|
||||
Reference in New Issue
Block a user