How do you manage your OO code in Rust?

I have been running into bigger chunks of Rust in my project lately, so I started to think about how to manage files in Rust.

One thing which came to my mind is the way I manage my Node.JS modules. So I tried reproducing the structure with.. minor issues; but I made it work! How do you manage your Rust modules?

Btw.: Sample of the mentioned structure in Rust:

// /src/

// Three lines for import is still something I have to sort out...
mod foo;
use foo::_struct::Foo;
use foo::*;

fn main() {
    let f = Foo{ my_var: true, };
// /src/foo/

// Also not too pretty; so much boilerplate for a little source code distribution across files
pub mod _struct;
pub mod say_hello;
pub use self::say_hello::SayHello;
// /src/foo/

 * Struct with all the import fields goes here!
 * I will probably have to add all the methods as comments here to have one single interface...
pub struct Foo {
    pub my_var: bool,

     * Write a friendly "Hello" to the console
     * fn say_hello(&self);
// /src/foo/

use super::_struct::Foo;

pub trait SayHello {
    fn say_hello(&self);

impl SayHello for Foo {
    fn say_hello(&self) {
        println!("Hellow World <3");
Write your answer…

Be the first one to answer this question