Exporting module code vs declaring module pub

What's the difference between

// src/lib.rs
mod a {
    pub use self::b::Foo;
    mod b {
        pub trait Foo {
            fn foo(&self);
        }
    }
}

and

// src/lib.rs
mod a {
    pub mod b {
        pub trait Foo {
            fn foo(&self);
        }
    }
}

Is it simply a difference of being able to qualify as either a::Foo and a::b::Foo in lib.rs? In all cases, must trait Foo be pub (pub trait Foo)?

Yes and Yes.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.