@@ -154,11 +154,8 @@ pub struct PyContext {
154
154
}
155
155
156
156
fn _nothing ( ) -> PyObjectRef {
157
- PyObject {
158
- payload : PyObjectPayload :: NoPayload ,
159
- typ : None ,
160
- }
161
- . into_ref ( )
157
+ let obj: PyObject = Default :: default ( ) ;
158
+ obj. into_ref ( )
162
159
}
163
160
164
161
pub fn create_type (
@@ -727,10 +724,11 @@ impl Default for PyContext {
727
724
/// This is an actual python object. It consists of a `typ` which is the
728
725
/// python class, and carries some rust payload optionally. This rust
729
726
/// payload can be a rust float or rust int in case of float and int objects.
727
+ #[ derive( Default ) ]
730
728
pub struct PyObject {
731
729
pub payload : PyObjectPayload ,
732
730
pub typ : Option < PyObjectRef > ,
733
- // pub dict: HashMap<String, PyObjectRef>, // __dict__ member
731
+ pub dict : Option < HashMap < String , PyObjectRef > > , // __dict__ member
734
732
}
735
733
736
734
pub trait IdProtocol {
@@ -1507,6 +1505,12 @@ pub enum PyObjectPayload {
1507
1505
} ,
1508
1506
}
1509
1507
1508
+ impl Default for PyObjectPayload {
1509
+ fn default ( ) -> Self {
1510
+ PyObjectPayload :: NoPayload
1511
+ }
1512
+ }
1513
+
1510
1514
impl fmt:: Debug for PyObjectPayload {
1511
1515
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1512
1516
match self {
@@ -1541,14 +1545,11 @@ impl fmt::Debug for PyObjectPayload {
1541
1545
}
1542
1546
1543
1547
impl PyObject {
1544
- pub fn new (
1545
- payload : PyObjectPayload ,
1546
- /* dict: PyObjectRef,*/ typ : PyObjectRef ,
1547
- ) -> PyObjectRef {
1548
+ pub fn new ( payload : PyObjectPayload , typ : PyObjectRef ) -> PyObjectRef {
1548
1549
PyObject {
1549
1550
payload,
1550
1551
typ : Some ( typ) ,
1551
- // dict: HashMap::new(), // dict ,
1552
+ dict : None ,
1552
1553
}
1553
1554
. into_ref ( )
1554
1555
}
0 commit comments