Closed glenn-horton-smith closed 4 years ago
Seems to work fine. Are you using an old Rust version or edition? This happens on edition 2015. On edition 2018, that extern crate
statement is not needed.
I think I'm using a very recent nightly: "rustup show" tells me the active chain is using "rustc 1.46.0-nightly (346aec9b0 2020-07-11)".
$ rustup show Default host: x86_64-unknown-linux-gnu rustup home: /home/gahs/.rustup installed toolchains -------------------- stable-x86_64-unknown-linux-gnu nightly-x86_64-unknown-linux-gnu (default) active toolchain ---------------- nightly-x86_64-unknown-linux-gnu (default) rustc 1.46.0-nightly (346aec9b0 2020-07-11)
And rustc --version
tells me the same thing.
I did another complete "rustup update" just in case, and there is no change. If I don't have the extern crate inline_python statement then I get
Compiling inline_python_example v0.0.1 (/home/gahs/Documents/proglangs/rust/demo/inline_python_example) error[E0432]: unresolved import `inline_python` --> src/bin/star.rs:2:5 | 2 | use inline_python::{python}; | ^^^^^^^^^^^^^ maybe a missing crate `inline_python`?
What am I doing wrong?
Sure, but are you using edition = "2018"
? cargo new
should;ve automatically put that in your Cargo.toml
. If you don't have that there, you're using Rust 2015, which requires extern crate ..
.
Ah, stupid me! Thanks, that was the problem. Clearly I need to learn to always start new things with cargo new
rather than reusing an existing example. Now everything works without extern crate
. Closing this.
By the way, I seem to have discovered by accident that it is not necessary (with the latest nightly) to have
#![feature(proc_macro_hygiene)]
Perhaps that's not a stable thing, but it is interesting.
Thanks for the help and thanks for inline-python!
Yes, that got into stable today, just a few hours ago. :) We'll be updating our crates soon.
I found that the example given in the documentation and the README.md file would not compile with "cargo build" or "cargo run" unless I added the line
extern crate inline_python;
before the "use" statement. (I suspect this may be a hyphen thing.) Adding the line to the example in the docs.rs and github examples would save newcomers a little head scratching.