Improve Debug output for GString
@@ -15,10 +15,8 @@ use std::string::String;
use crate::value::{FromValueOptional, SetValue, SetValueOptional, Value};
-#[derive(Debug)]
pub struct GString(Inner);
-#[derive(Debug)]
enum Inner {
Native(Option<CString>),
Foreign(*mut c_char, usize),
@@ -88,6 +86,12 @@ impl Clone for GString {
}
}
+impl fmt::Debug for GString {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ <&str as fmt::Debug>::fmt(&self.as_str(), f)
+ }
+}
+
impl Drop for GString {
fn drop(&mut self) {
if let GString(Inner::Foreign(ptr, _len)) = self {
