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;








1
















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 module my/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.









share|improve this 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

















1
















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 module my/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.









share|improve this 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













1












1








1









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 module my/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.









share|improve this question















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 module my/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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















1














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,








share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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,








    share|improve this answer





























      1














      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,








      share|improve this answer



























        1












        1








        1







        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,








        share|improve this answer















        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,









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 8 at 19:04

























        answered Mar 8 at 18:59









        onlycparraonlycparra

        679




        679















            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved