I am migrating a rust project to python and need to understand how a function is working. I know a little about rust but am hardly an expert
I simply want to be able to import log::warn
into ab_data.rs
so I can trace the logic.
The project structure is:
/src
lib.rs
/app
main.rs
...
/models/
ab_data.rs
...
However, it's not simple. I've tried multiple ways to get ab_data.rs
to import log
,
and get messages like:
|
9 | use log;
| ^^^ no `log` in the root
lib.rs
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]
#[macro_use]
extern crate log;
extern crate mysql;
extern crate pwhash;
extern crate chrono;
extern crate rand;
extern crate itertools;
...
app/main.rs
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]
#[macro_use]
extern crate log;
extern crate mysql;
extern crate pwhash;
extern crate chrono;
extern crate rand;
extern crate itertools;
...
app/models/ab_data.rs
use models::{Date, User};
use mysql;
use mysql::{Pool, Row};
use log;
use log::{warn};
...
impl AbData {
/// Takes an input struct, and returns an output struct with all fields calculated.
pub fn calculate(...) -> Self {
warn!('warn message');
...
Cargo.toml
...
[[bin]]
...
path = "src/app/main.rs"
...
[dependencies]
...
log = "0.3.8"
mysql = "11.3"
...
[dev-dependencies]
assert_approx_eq = "1.0"
[lib]
path = "src/lib.rs"
Dockerfile
RUN rustup install nightly-2018-03-15
RUN rustup default nightly-2018-03-15
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN cargo build --release
...
Note that the mysql import works in this module, and I believe I'm following the exact same pattern for log, but it cannot be located.
I'm not a rust programmer, as I mentioned. Any help is appreciated. Let me know if I missed anything important.