File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
exercises/01_intro/02_modules Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ version = "0.1.0"
4
4
edition = " 2021"
5
5
6
6
[lib ]
7
+ # Setting "name" here is optional. If not set, by default the value in the [package] section is used.
8
+ # name = "modules"
7
9
crate-type = [" cdylib" ]
8
10
9
11
[dependencies ]
Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ fn it_works() -> bool {
6
6
true
7
7
}
8
8
9
- /// A Python module implemented in Rust.
9
+ // A Python module implemented in Rust.
10
+ // When Python imports a module names `modules`, it's looking for a function called
11
+ // PyInit_modules. Rust code here was creating a function named `learn_modules`.
12
+ // The module name in Rust code **must** match the library name.
10
13
#[ pymodule]
11
- fn learn_modules ( m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
14
+ fn modules ( m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
12
15
m. add_function ( wrap_pyfunction ! ( it_works, m) ?) ?;
13
16
Ok ( ( ) )
14
17
}
You can’t perform that action at this time.
0 commit comments