diff options
Diffstat (limited to 'src/cxx_string.rs')
-rw-r--r-- | src/cxx_string.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cxx_string.rs b/src/cxx_string.rs index 9ecbcc64..496d3bec 100644 --- a/src/cxx_string.rs +++ b/src/cxx_string.rs @@ -241,7 +241,7 @@ impl Eq for CxxString {} impl PartialOrd for CxxString { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - self.as_bytes().partial_cmp(other.as_bytes()) + Some(self.cmp(other)) } } @@ -257,6 +257,25 @@ impl Hash for CxxString { } } +impl fmt::Write for Pin<&mut CxxString> { + fn write_str(&mut self, s: &str) -> fmt::Result { + self.as_mut().push_str(s); + Ok(()) + } +} + +#[cfg(feature = "std")] +impl std::io::Write for Pin<&mut CxxString> { + fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { + self.as_mut().push_bytes(buf); + Ok(buf.len()) + } + + fn flush(&mut self) -> std::io::Result<()> { + Ok(()) + } +} + #[doc(hidden)] #[repr(C)] pub struct StackString { |