Skip to content

Commit f2a9f36

Browse files
committed
use pyo3 0.1 for example
1 parent 866b0f4 commit f2a9f36

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
CHANGES
22
=======
33

4+
- Use PyO3 0.1 for example.
5+
6+
47
0.6.4 (2017-07-31)
58
------------------
69

example/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ version = "0.1.0"
44
authors = ["Nikolay Kim <[email protected]>"]
55

66
[dependencies.pyo3]
7-
git = "https://github.com/PyO3/PyO3.git"
7+
version = "0.1.0"
88
default-features = false
99

1010
[lib]
1111
name = "helloworld"
12-
crate-type = ["cdylib"]

example/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ extern crate pyo3;
44

55
use pyo3::*;
66

7+
/// Module documentation string
78
#[py::modinit(_helloworld)]
89
fn init(py: Python, m: &PyModule) -> PyResult<()> {
9-
m.add(py, "__doc__", "Module documentation string")?;
1010

11-
#[pyfn(m, "run", "*args, **kwargs")]
11+
#[pyfn(m, "run", args="*", kwargs="**")]
1212
fn run_fn(py: Python, args: &PyTuple, kwargs: Option<&PyDict>) -> PyResult<()> {
1313
run(py, args, kwargs)
1414
}
@@ -23,12 +23,12 @@ fn init(py: Python, m: &PyModule) -> PyResult<()> {
2323

2424
fn run(py: Python, args: &PyTuple, kwargs: Option<&PyDict>) -> PyResult<()> {
2525
println!("Rust says: Hello Python!");
26-
for arg in args.iter(py) {
27-
println!("Rust got {}", arg);
26+
for arg in args.iter() {
27+
println!("Rust got {}", arg.as_ref(py));
2828
}
2929
if let Some(kwargs) = kwargs {
30-
for (key, val) in kwargs.items(py) {
31-
println!("{} = {}", key, val);
30+
for (key, val) in kwargs.items_vec() {
31+
println!("{} = {}", key.as_ref(py), val.as_ref(py));
3232
}
3333
}
3434
Ok(())

0 commit comments

Comments
 (0)