Merge pull request #337 from Alexander-N/fix-examples
Fix some examples
This commit is contained in:
commit
7e914ac535
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue