Skip to content

Commit 445cb6c

Browse files
committed
Format
1 parent 88299ef commit 445cb6c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

examples/call_between_rust_and_python.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustpython_vm::{
2-
pyclass, pymodule, PyObject, PyPayload, PyResult, TryFromBorrowedObject,
3-
VirtualMachine,
2+
pyclass, pymodule, PyObject, PyPayload, PyResult, TryFromBorrowedObject, VirtualMachine,
43
};
54

65
pub(crate) use rust_py_module::make_module;
@@ -20,7 +19,11 @@ pub fn main() {
2019
vm.invoke(&init_fn, ()).unwrap();
2120

2221
let take_string_fn = module.get_attr("take_string", vm).unwrap();
23-
vm.invoke(&take_string_fn, (String::from("Rust string sent to python"),)).unwrap();
22+
vm.invoke(
23+
&take_string_fn,
24+
(String::from("Rust string sent to python"),),
25+
)
26+
.unwrap();
2427
})
2528
}
2629

@@ -40,9 +43,7 @@ mod rust_py_module {
4043
num: {},
4144
string: {},
4245
python_person.name: {}",
43-
num,
44-
s,
45-
python_person.name
46+
num, s, python_person.name
4647
);
4748
Ok(RustStruct)
4849
}
@@ -66,9 +67,7 @@ python_person.name: {}",
6667

6768
impl TryFromBorrowedObject for PythonPerson {
6869
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
69-
let name = obj
70-
.get_attr("name", vm)?
71-
.try_into_value::<String>(vm)?;
70+
let name = obj.get_attr("name", vm)?.try_into_value::<String>(vm)?;
7271
Ok(PythonPerson { name })
7372
}
7473
}

0 commit comments

Comments
 (0)