@@ -155,13 +155,8 @@ pub struct PyContext {
155
155
}
156
156
157
157
fn _nothing ( ) -> PyObjectRef {
158
- PyObject {
159
- payload : PyObjectPayload :: AnyRustValue {
160
- value : Box :: new ( ( ) ) ,
161
- } ,
162
- typ : None ,
163
- }
164
- . into_ref ( )
158
+ let obj: PyObject = Default :: default ( ) ;
159
+ obj. into_ref ( )
165
160
}
166
161
167
162
pub fn create_type (
@@ -745,10 +740,11 @@ impl Default for PyContext {
745
740
/// This is an actual python object. It consists of a `typ` which is the
746
741
/// python class, and carries some rust payload optionally. This rust
747
742
/// payload can be a rust float or rust int in case of float and int objects.
743
+ #[ derive( Default ) ]
748
744
pub struct PyObject {
749
745
pub payload : PyObjectPayload ,
750
746
pub typ : Option < PyObjectRef > ,
751
- // pub dict: HashMap<String, PyObjectRef>, // __dict__ member
747
+ pub dict : Option < HashMap < String , PyObjectRef > > , // __dict__ member
752
748
}
753
749
754
750
pub trait IdProtocol {
@@ -1538,6 +1534,14 @@ pub enum PyObjectPayload {
1538
1534
} ,
1539
1535
}
1540
1536
1537
+ impl Default for PyObjectPayload {
1538
+ fn default ( ) -> Self {
1539
+ PyObjectPayload :: AnyRustValue {
1540
+ value : Box :: new ( ( ) ) ,
1541
+ }
1542
+ }
1543
+ }
1544
+
1541
1545
impl fmt:: Debug for PyObjectPayload {
1542
1546
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1543
1547
match self {
@@ -1568,14 +1572,11 @@ impl fmt::Debug for PyObjectPayload {
1568
1572
}
1569
1573
1570
1574
impl PyObject {
1571
- pub fn new (
1572
- payload : PyObjectPayload ,
1573
- /* dict: PyObjectRef,*/ typ : PyObjectRef ,
1574
- ) -> PyObjectRef {
1575
+ pub fn new ( payload : PyObjectPayload , typ : PyObjectRef ) -> PyObjectRef {
1575
1576
PyObject {
1576
1577
payload,
1577
1578
typ : Some ( typ) ,
1578
- // dict: HashMap::new(), // dict ,
1579
+ dict : None ,
1579
1580
}
1580
1581
. into_ref ( )
1581
1582
}
0 commit comments