File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 9
9
//!
10
10
//! See the [book](https://kdab.github.io/cxx-qt/book/) for more information.
11
11
12
+ use std:: pin:: Pin ;
12
13
use std:: { fs:: File , io:: Write , path:: Path } ;
13
14
14
15
#[ doc( hidden) ]
@@ -125,6 +126,27 @@ pub use threading::{CxxQtThread, ThreadingQueueError};
125
126
#[ doc( hidden) ]
126
127
pub use static_assertions;
127
128
129
+ /// This trait provides wrappers for objects which are QObjects or can be turned into a [QObject].
130
+ /// It is automatically implemented for any types which implement [Upcast] to a [QObject].
131
+ pub trait AsObject {
132
+ /// Cast self reference into a [QObject] reference
133
+ fn as_qobject ( & self ) -> & QObject ;
134
+
135
+ /// Cast pinned mutable reference into a pinned mutable [QObject] reference
136
+ fn as_qobject_mut ( self : Pin < & mut Self > ) -> Pin < & mut QObject > ;
137
+ }
138
+
139
+ impl < T : casting:: Upcast < QObject > > AsObject for T {
140
+ fn as_qobject ( & self ) -> & QObject {
141
+ self . upcast ( )
142
+ }
143
+
144
+
145
+ fn as_qobject_mut ( self : Pin < & mut Self > ) -> Pin < & mut QObject > {
146
+ self . upcast_pin ( )
147
+ }
148
+ }
149
+
128
150
/// This trait is automatically implemented for all QObject types generated by CXX-Qt.
129
151
/// It provides information about the inner Rust struct that is wrapped by the QObject, as well as the methods
130
152
/// that Cxx-Qt will generate for the QObject.
You can’t perform that action at this time.
0 commit comments