11use rustpython_vm:: {
2- pyclass, pymodule, PyObject , PyPayload , PyResult , TryFromBorrowedObject ,
3- VirtualMachine ,
2+ pyclass, pymodule, PyObject , PyPayload , PyResult , TryFromBorrowedObject , VirtualMachine ,
43} ;
54
65pub ( 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 {
4043num: {},
4144string: {},
4245python_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