1
1
use rustpython_vm:: {
2
- pyclass, pymodule, PyObject , PyPayload , PyResult , TryFromBorrowedObject ,
3
- VirtualMachine ,
2
+ pyclass, pymodule, PyObject , PyPayload , PyResult , TryFromBorrowedObject , VirtualMachine ,
4
3
} ;
5
4
6
5
pub ( crate ) use rust_py_module:: make_module;
@@ -20,7 +19,11 @@ pub fn main() {
20
19
vm. invoke ( & init_fn, ( ) ) . unwrap ( ) ;
21
20
22
21
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 ( ) ;
24
27
} )
25
28
}
26
29
@@ -40,9 +43,7 @@ mod rust_py_module {
40
43
num: {},
41
44
string: {},
42
45
python_person.name: {}" ,
43
- num,
44
- s,
45
- python_person. name
46
+ num, s, python_person. name
46
47
) ;
47
48
Ok ( RustStruct )
48
49
}
@@ -66,9 +67,7 @@ python_person.name: {}",
66
67
67
68
impl TryFromBorrowedObject for PythonPerson {
68
69
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) ?;
72
71
Ok ( PythonPerson { name } )
73
72
}
74
73
}
0 commit comments