mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 19:24:57 +08:00
Add or make public get_elements for sequences/dicts
This commit is contained in:
1 parent
e0b71b8d93
commit
934612314b
3 files changed
+10
-2
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ pub fn new(dict_type: PyObjectRef) -> PyObjectRef {
|
||||
)
|
||||
}
|
||||
|
||||
fn get_elements(obj: &PyObjectRef) -> HashMap<String, PyObjectRef> {
|
||||
pub fn get_elements(obj: &PyObjectRef) -> HashMap<String, PyObjectRef> {
|
||||
if let PyObjectKind::Dict { elements } = &obj.borrow().kind {
|
||||
elements.clone()
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ pub fn set_item(
|
||||
}
|
||||
}
|
||||
|
||||
fn get_elements(obj: PyObjectRef) -> Vec<PyObjectRef> {
|
||||
pub fn get_elements(obj: PyObjectRef) -> Vec<PyObjectRef> {
|
||||
if let PyObjectKind::List { elements } = &obj.borrow().kind {
|
||||
elements.to_vec()
|
||||
} else {
|
||||
|
||||
@@ -98,3 +98,11 @@ pub fn get_item(
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_elements(obj: PyObjectRef) -> Vec<PyObjectRef> {
|
||||
if let PyObjectKind::Tuple { elements } = &obj.borrow().kind {
|
||||
elements.to_vec()
|
||||
} else {
|
||||
panic!("Cannot extract list elements from non-list");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user