Merge pull request #337 from Alexander-N/fix-examples

Fix some examples
This commit is contained in:
konstin 2019-02-07 15:21:26 +01:00 committed by GitHub
commit 7e914ac535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -332,6 +332,7 @@ with `#[call]` attribute. Arguments of the method are specified same as for inst
```rust
# use pyo3::prelude::*;
use pyo3::types::PyTuple;
# #[pyclass]
# struct MyClass {
# num: i32,
@ -374,6 +375,7 @@ Each parameter could one of following type:
Example:
```rust
# use pyo3::prelude::*;
use pyo3::types::{PyDict, PyTuple};
#
# #[pyclass]
# struct MyClass {
@ -519,15 +521,15 @@ Example:
```rust
use pyo3::prelude::*;
use pyo3::PyIterProtocol;
#[pyclass]
struct MyIterator {
iter: Box<Iterator<Item=PyObject> + Send>,
iter: Box<Iterator<Item = PyObject> + Send>,
}
#[pyproto]
impl PyIterProtocol for MyIterator {
fn __iter__(&mut self) -> PyResult<PyObject> {
Ok(self.into())
}

View file

@ -43,18 +43,19 @@ rust tuple with up to 10 elements. Or `NoArgs` object which represents empty tup
```rust
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyTuple};
struct SomeObject;
impl SomeObject {
fn new(py: Python) -> PyObject {
pyo3::PyDict::new(py).to_object(py)
PyDict::new(py).to_object(py)
}
}
fn main() {
# let arg1 = "arg1";
# let arg2 = "arg2";
# let arg3 = "arg3";
let arg1 = "arg1";
let arg2 = "arg2";
let arg3 = "arg3";
let gil = Python::acquire_gil();
let py = gil.python();