Rust 2018: an early preview

I like most stuff, but I’m not a fan of the anti-pub lint in binary programs. It sounds nicer to me to make my structs “public”, even if public is restricted to the local crate in this case. I always thought of crate as something that is used only in libraries when pub means super public, and something that wouldn’t be used that much. But now it seems like crate has completely replaced pub in binary programs and I’m not a fan of that. It’s longer, and if I ever want to separate stuff into a library then that’s going to be more difficult, renaming all the crates to pub.

3 Likes

Maybe pub can be made to mean pub(crate) and pub(api) (or pub(extern)) to mean pub?

The more public an item is, the longer access specifier it should have.

4 Likes

I make stuff pub in binaries sometimes so I can generate docs for them, for my own use.

1 Like

Slightly off-topic in here, but if it’s for your own use, you can pass --document-private-items to rustdoc.

3 Likes

Actually, what I tend to do these days is put whatever the logic of my command line app is in a library (lib.rs), and then add a (bin/cmd.rs) with just the args parsing, logger setup etc.

4 Likes

Links in the OP don’t work.

Looks like some of the pages have been moved around. You can still read the edition guide here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.