Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 899f874

Browse files
committed
Implement fmt::Debug for subclass::simple::{InstanceStruct, ClassStruct}
1 parent 2b0b4c2 commit 899f874

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/subclass/simple.rs

+23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use super::prelude::*;
1010
use object::ObjectType;
1111

12+
use std::fmt;
1213
use std::ops;
1314

1415
/// A simple instance struct that does not store any additional data.
@@ -17,6 +18,17 @@ pub struct InstanceStruct<T: ObjectSubclass> {
1718
parent: <T::ParentType as ObjectType>::GlibType,
1819
}
1920

21+
impl<T: ObjectSubclass> fmt::Debug for InstanceStruct<T>
22+
where
23+
<T::ParentType as ObjectType>::GlibType: fmt::Debug,
24+
{
25+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
26+
f.debug_struct("InstanceStruct")
27+
.field("parent", &self.parent)
28+
.finish()
29+
}
30+
}
31+
2032
unsafe impl<T: ObjectSubclass> super::types::InstanceStruct for InstanceStruct<T> {
2133
type Type = T;
2234
}
@@ -28,6 +40,17 @@ pub struct ClassStruct<T: ObjectSubclass> {
2840
parent_class: <T::ParentType as ObjectType>::GlibClassType,
2941
}
3042

43+
impl<T: ObjectSubclass> fmt::Debug for ClassStruct<T>
44+
where
45+
<T::ParentType as ObjectType>::GlibClassType: fmt::Debug,
46+
{
47+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
48+
f.debug_struct("InstanceStruct")
49+
.field("parent_class", &self.parent_class)
50+
.finish()
51+
}
52+
}
53+
3154
unsafe impl<T: ObjectSubclass> super::types::ClassStruct for ClassStruct<T> {
3255
type Type = T;
3356
}

0 commit comments

Comments
 (0)