mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Eliminate NoPayload and just use a boxed ().
This commit is contained in:
1 parent
a72af4d967
commit
e0c398cbd5
1 file changed
+15
-6
+15
-6
@@ -155,7 +155,9 @@ pub struct PyContext {
|
||||
|
||||
fn _nothing() -> PyObjectRef {
|
||||
PyObject {
|
||||
payload: PyObjectPayload::NoPayload,
|
||||
payload: PyObjectPayload::AnyRustValue {
|
||||
value: Box::new(()),
|
||||
},
|
||||
typ: None,
|
||||
}
|
||||
.into_ref()
|
||||
@@ -223,14 +225,23 @@ impl PyContext {
|
||||
let exceptions = exceptions::ExceptionZoo::new(&type_type, &object_type, &dict_type);
|
||||
|
||||
let none = PyObject::new(
|
||||
PyObjectPayload::NoPayload,
|
||||
PyObjectPayload::AnyRustValue {
|
||||
value: Box::new(()),
|
||||
},
|
||||
create_type("NoneType", &type_type, &object_type, &dict_type),
|
||||
);
|
||||
|
||||
let ellipsis = PyObject::new(PyObjectPayload::NoPayload, ellipsis_type.clone());
|
||||
let ellipsis = PyObject::new(
|
||||
PyObjectPayload::AnyRustValue {
|
||||
value: Box::new(()),
|
||||
},
|
||||
ellipsis_type.clone(),
|
||||
);
|
||||
|
||||
let not_implemented = PyObject::new(
|
||||
PyObjectPayload::NoPayload,
|
||||
PyObjectPayload::AnyRustValue {
|
||||
value: Box::new(()),
|
||||
},
|
||||
create_type("NotImplementedType", &type_type, &object_type, &dict_type),
|
||||
);
|
||||
|
||||
@@ -1484,7 +1495,6 @@ pub enum PyObjectPayload {
|
||||
name: String,
|
||||
scope: ScopeRef,
|
||||
},
|
||||
NoPayload,
|
||||
Class {
|
||||
name: String,
|
||||
dict: RefCell<PyAttributes>,
|
||||
@@ -1525,7 +1535,6 @@ impl fmt::Debug for PyObjectPayload {
|
||||
ref object,
|
||||
} => write!(f, "bound-method: {:?} of {:?}", function, object),
|
||||
PyObjectPayload::Module { .. } => write!(f, "module"),
|
||||
PyObjectPayload::NoPayload => write!(f, "NoPayload"),
|
||||
PyObjectPayload::Class { ref name, .. } => write!(f, "class {:?}", name),
|
||||
PyObjectPayload::Instance { .. } => write!(f, "instance"),
|
||||
PyObjectPayload::RustFunction { .. } => write!(f, "rust function"),
|
||||
|
||||
Reference in new issue
Block a user