Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring the modules in lib.rs, not main.rs #1

Open
dxps opened this issue Feb 23, 2020 · 0 comments
Open

Declaring the modules in lib.rs, not main.rs #1

dxps opened this issue Feb 23, 2020 · 0 comments

Comments

@dxps
Copy link

dxps commented Feb 23, 2020

Hi Siva,

Got here based on your article on Medium. The approach is explained in a simple and straight to the point manner.

What I actually like to do is to declare the modules in lib.rs, considering main.rs (or any other [[bin]] for this matter) to be responsible of just using it, and not also declare it.

This means:

  • instead of having both the declaration and usage of a module in main.rs:
    mod blog;
    use blog::Post;
  • we could have the module(s) declared in lib.rs:
    pub mod blog;
    with blog.rs being in the same location (src) as lib.rs

    and `main would just use them:
    use {package-name}::blog::Post;

What do you think? Is it just a subjective perspective?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant