I am trying to create a module in Rust and then use it from another file. This is my file structure:
matthias@X1 :~/projects/bitter-oyster$ tree . βββ Cargo.lock βββ Cargo.toml βββ Readme.md βββ src β βββ liblib.rlib β βββ lib.rs β βββ main.rs β βββ main.rs~ β βββ plot β βββ line.rs β βββ mod.rs βββ target βββ debug βββ bitter_oyster.d βββ build βββ deps βββ examples βββ libbitter_oyster.rlib βββ native 8 directories, 11 files
This is Cargo.toml:
[package] name = "bitter-oyster" version = "0.1.0" authors = ["matthias"] [dependencies]
This is main.rs:
extern crate plot; fn main() { println!("----"); plot::line::test(); }
This is lib.rs:
mod plot;
this is plot / mod.rs
mod line;
and this is plot / line.rs
pub fn test(){ println!("Here line"); }
When I try to compile my program using: cargo run , I get:
Compiling bitter-oyster v0.1.0 (file:///home/matthias/projects/bitter-oyster) /home/matthias/projects/bitter-oyster/src/main.rs:1:1: 1:19 error: can't find crate for `plot` [E0463] /home/matthias/projects/bitter-oyster/src/main.rs:1 extern crate plot;
How do I compile my program? As far as I can tell from online docs, this should work, but it is not.
rust rust-crates
Stein
source share