Merge pull request #18 from traff/master
A method for accessing dictionary items.
This commit is contained in:
commit
f6718a271b
|
@ -19,7 +19,7 @@
|
||||||
use ffi;
|
use ffi;
|
||||||
use python::{Python, ToPythonPointer, PythonObject};
|
use python::{Python, ToPythonPointer, PythonObject};
|
||||||
use conversion::ToPyObject;
|
use conversion::ToPyObject;
|
||||||
use objects::PyObject;
|
use objects::{PyObject, PyList};
|
||||||
use err::{self, PyResult, PyErr};
|
use err::{self, PyResult, PyErr};
|
||||||
|
|
||||||
/// Represents a Python `dict`.
|
/// Represents a Python `dict`.
|
||||||
|
@ -102,5 +102,13 @@ impl <'p> PyDict<'p> {
|
||||||
ffi::PyDict_DelItem(self.as_ptr(), key))
|
ffi::PyDict_DelItem(self.as_ptr(), key))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// List of dict items.
|
||||||
|
// This is equivalent to the `dict.items()` method.
|
||||||
|
pub fn items(&self) -> PyList {
|
||||||
|
let py = self.python();
|
||||||
|
unsafe {
|
||||||
|
err::cast_from_owned_ptr_or_panic(py, ffi::PyDict_Items(self.as_ptr()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue