How to split the code in modules in Rust? [duplicate] Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Can't understand Rust module systemModule visibility in RustHow can I get a list of locally installed Python modules?How to include module from another file from the same project?Why does Rust fail to link on Windows?Unable to coerce &String to &strWhy are explicit lifetimes needed in Rust?Access functions from sub-module from other sub-moduleHow do 'use' and 'mod' work when there are nested source directories?How am I messing up these modules?How to divide my program in modules?How to use one module from another module in a Rust cargo project?
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
How to answer "Have you ever been terminated?"
Would "destroying" Wurmcoil Engine prevent its tokens from being created?
Circuit to "zoom in" on mV fluctuations of a DC signal?
Fundamental Solution of the Pell Equation
Is it a good idea to use CNN to classify 1D signal?
Why aren't air breathing engines used as small first stages
What font is "z" in "z-score"?
Using audio cues to encourage good posture
How does the math work when buying airline miles?
Around usage results
How come Sam didn't become Lord of Horn Hill?
How could we fake a moon landing now?
When the Haste spell ends on a creature, do attackers have advantage against that creature?
How to find all the available tools in mac terminal?
old style "caution" boxes
Is the Standard Deduction better than Itemized when both are the same amount?
Extracting terms with certain heads in a function
Is "Reachable Object" really an NP-complete problem?
Is there a kind of relay only consumes power when switching?
Generate an RGB colour grid
Maximum summed powersets with non-adjacent items
Should I use a zero-interest credit card for a large one-time purchase?
2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?
How to split the code in modules in Rust? [duplicate]
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Can't understand Rust module systemModule visibility in RustHow can I get a list of locally installed Python modules?How to include module from another file from the same project?Why does Rust fail to link on Windows?Unable to coerce &String to &strWhy are explicit lifetimes needed in Rust?Access functions from sub-module from other sub-moduleHow do 'use' and 'mod' work when there are nested source directories?How am I messing up these modules?How to divide my program in modules?How to use one module from another module in a Rust cargo project?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This question already has an answer here:
Can't understand Rust module system
1 answer
I am reading the Rust Book, I am in the chapter 7.2, but I must be missing something, because I cannot organize my code in modules, the compiler (rustc 1.32.0) keeps giving me errors.
What I have read
- I read
rustc --explain E0433
, which is the advice of the compiler, but I still cannot solve it. - I checked Rust by examples, and it seems that my code is correct, (
my/mod.rs
is using modulemy/nested.rs
in its own folder) - I found some info on Internet, but it is of 4 years ago, and include the use of
use
, which is not yet in the book. - I also checked this question, but I am not using folders, and again, it gets away from the book explanation.
Minimal example
This is a minimal example that tries to mimic the "sound" example of the book, there is only two files: /src/main.rs
and /src/m.rs
.
main.rs
mod m;
fn main()
let st_0 = m::St::new();
m.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
And this is what cargo
tells me:
Compiling min v0.1.0 (/home/user/min)
error[E0433]: failed to resolve: could not find `St` in `m`
--> src/main.rs:3:19
|
3 | let st_0 = m::St::new();
| ^^ could not find `St` in `m`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `min`.
To learn more, run the command again with --verbose.
module compiler-errors rust
marked as duplicate by E_net4, Sven Marnach, trentcl, Peter Hall, Frxstrem Mar 9 at 13:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Can't understand Rust module system
1 answer
I am reading the Rust Book, I am in the chapter 7.2, but I must be missing something, because I cannot organize my code in modules, the compiler (rustc 1.32.0) keeps giving me errors.
What I have read
- I read
rustc --explain E0433
, which is the advice of the compiler, but I still cannot solve it. - I checked Rust by examples, and it seems that my code is correct, (
my/mod.rs
is using modulemy/nested.rs
in its own folder) - I found some info on Internet, but it is of 4 years ago, and include the use of
use
, which is not yet in the book. - I also checked this question, but I am not using folders, and again, it gets away from the book explanation.
Minimal example
This is a minimal example that tries to mimic the "sound" example of the book, there is only two files: /src/main.rs
and /src/m.rs
.
main.rs
mod m;
fn main()
let st_0 = m::St::new();
m.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
And this is what cargo
tells me:
Compiling min v0.1.0 (/home/user/min)
error[E0433]: failed to resolve: could not find `St` in `m`
--> src/main.rs:3:19
|
3 | let st_0 = m::St::new();
| ^^ could not find `St` in `m`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `min`.
To learn more, run the command again with --verbose.
module compiler-errors rust
marked as duplicate by E_net4, Sven Marnach, trentcl, Peter Hall, Frxstrem Mar 9 at 13:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39
add a comment |
This question already has an answer here:
Can't understand Rust module system
1 answer
I am reading the Rust Book, I am in the chapter 7.2, but I must be missing something, because I cannot organize my code in modules, the compiler (rustc 1.32.0) keeps giving me errors.
What I have read
- I read
rustc --explain E0433
, which is the advice of the compiler, but I still cannot solve it. - I checked Rust by examples, and it seems that my code is correct, (
my/mod.rs
is using modulemy/nested.rs
in its own folder) - I found some info on Internet, but it is of 4 years ago, and include the use of
use
, which is not yet in the book. - I also checked this question, but I am not using folders, and again, it gets away from the book explanation.
Minimal example
This is a minimal example that tries to mimic the "sound" example of the book, there is only two files: /src/main.rs
and /src/m.rs
.
main.rs
mod m;
fn main()
let st_0 = m::St::new();
m.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
And this is what cargo
tells me:
Compiling min v0.1.0 (/home/user/min)
error[E0433]: failed to resolve: could not find `St` in `m`
--> src/main.rs:3:19
|
3 | let st_0 = m::St::new();
| ^^ could not find `St` in `m`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `min`.
To learn more, run the command again with --verbose.
module compiler-errors rust
This question already has an answer here:
Can't understand Rust module system
1 answer
I am reading the Rust Book, I am in the chapter 7.2, but I must be missing something, because I cannot organize my code in modules, the compiler (rustc 1.32.0) keeps giving me errors.
What I have read
- I read
rustc --explain E0433
, which is the advice of the compiler, but I still cannot solve it. - I checked Rust by examples, and it seems that my code is correct, (
my/mod.rs
is using modulemy/nested.rs
in its own folder) - I found some info on Internet, but it is of 4 years ago, and include the use of
use
, which is not yet in the book. - I also checked this question, but I am not using folders, and again, it gets away from the book explanation.
Minimal example
This is a minimal example that tries to mimic the "sound" example of the book, there is only two files: /src/main.rs
and /src/m.rs
.
main.rs
mod m;
fn main()
let st_0 = m::St::new();
m.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
And this is what cargo
tells me:
Compiling min v0.1.0 (/home/user/min)
error[E0433]: failed to resolve: could not find `St` in `m`
--> src/main.rs:3:19
|
3 | let st_0 = m::St::new();
| ^^ could not find `St` in `m`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `min`.
To learn more, run the command again with --verbose.
This question already has an answer here:
Can't understand Rust module system
1 answer
module compiler-errors rust
module compiler-errors rust
asked Mar 8 at 18:59
onlycparraonlycparra
679
679
marked as duplicate by E_net4, Sven Marnach, trentcl, Peter Hall, Frxstrem Mar 9 at 13:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by E_net4, Sven Marnach, trentcl, Peter Hall, Frxstrem Mar 9 at 13:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39
add a comment |
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39
add a comment |
1 Answer
1
active
oldest
votes
When you have everything in one file, like this:
main.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
mod m;
fn main()
let st_0 = m::St::new();
you wrap the module with the
pub mod mode_name
//code...
Once you put the module in another file, that wrapping goes away. The Rust book, shows it, but if you don't look carefully or if you are programming drunk, you may get confused with the pub mod instrument ...
of the nested module.
So m.rs has to look like this:
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you have everything in one file, like this:
main.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
mod m;
fn main()
let st_0 = m::St::new();
you wrap the module with the
pub mod mode_name
//code...
Once you put the module in another file, that wrapping goes away. The Rust book, shows it, but if you don't look carefully or if you are programming drunk, you may get confused with the pub mod instrument ...
of the nested module.
So m.rs has to look like this:
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
add a comment |
When you have everything in one file, like this:
main.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
mod m;
fn main()
let st_0 = m::St::new();
you wrap the module with the
pub mod mode_name
//code...
Once you put the module in another file, that wrapping goes away. The Rust book, shows it, but if you don't look carefully or if you are programming drunk, you may get confused with the pub mod instrument ...
of the nested module.
So m.rs has to look like this:
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
add a comment |
When you have everything in one file, like this:
main.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
mod m;
fn main()
let st_0 = m::St::new();
you wrap the module with the
pub mod mode_name
//code...
Once you put the module in another file, that wrapping goes away. The Rust book, shows it, but if you don't look carefully or if you are programming drunk, you may get confused with the pub mod instrument ...
of the nested module.
So m.rs has to look like this:
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
When you have everything in one file, like this:
main.rs
pub mod m
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
mod m;
fn main()
let st_0 = m::St::new();
you wrap the module with the
pub mod mode_name
//code...
Once you put the module in another file, that wrapping goes away. The Rust book, shows it, but if you don't look carefully or if you are programming drunk, you may get confused with the pub mod instrument ...
of the nested module.
So m.rs has to look like this:
pub struct St
a:i32,
b:i32,
impl St
pub fn new() -> St
println!("New St!");
St
a: 12,
b: 13,
edited Mar 8 at 19:04
answered Mar 8 at 18:59
onlycparraonlycparra
679
679
add a comment |
add a comment |
It certainly is a duplicate, I didn't catch it before. What should I do with my question? Delete it?
– onlycparra
Mar 11 at 21:39