-
Notifications
You must be signed in to change notification settings - Fork 13k
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
RFC: make the stdlib more hierarchical #9208
Comments
Nominating for backwards compatible. |
1+, we don't need to get a complicated/detailed module hierarchy in the std lib, but something better than a flat list would definitely improve organisation and make related things easier to find.
Using modules would also mean the source files could get properly grouped in directories without needing the |
There was some discussion of reorganizing the various encoding modules in |
One thing we'd want to watch out for is making common types difficult to access, having to type I'm all for reorganization though if it collects things together nicely. |
modules like |
+1 to that, that would be awesome. |
accepted backwards-compatible (we're not committing to doing this; just, the decision is on milestone 2) |
New standards have arisen in recent months, mostly for the use of rustpkg, but the main Rust codebase has not been altered to match these new specifications. This changeset rectifies most of these issues. - Renamed the crate source files `src/libX/X.rs` to `lib.rs`, for consistency with current styles; this affects extra, rustc, rustdoc, rustpkg, rustuv, std, syntax. - Renamed `X/X.rs` to `X/mod.rs,` as is now recommended style, for `std::num` and `std::terminfo`. - Shifted `src/libstd/str/ascii.rs` out of the otherwise unused `str` directory, to be consistent with its import path of `std::ascii`; libstd is flat at present so it's more appropriate thus. While this removes some `#[path = "..."]` directives, it does not remove all of them, and leaves certain other inconsistencies, such as `std::u8` et al. which are actually stored in `src/libstd/num/` (one subdirectory down). No quorum has been reached on this issue, so I felt it best to leave them all alone at present. rust-lang#9208 deals with the possibility of making libstd more hierarchical (such as changing the crate to match the current filesystem structure, which would make the module path `std::num::u8`). There is one thing remaining in which this repository is not rustpkg-compliant: rustpkg would have `src/std/` et al. rather than `src/libstd/` et al. I have not endeavoured to change that at this point as it would guarantee prompt bitrot and confusion. A change of that magnitude needs to be discussed first.
New standards have arisen in recent months, mostly for the use of rustpkg, but the main Rust codebase has not been altered to match these new specifications. This changeset rectifies most of these issues. - Renamed the crate source files `src/libX/X.rs` to `lib.rs`, for consistency with current styles; this affects extra, rustc, rustdoc, rustpkg, std, syntax. - Renamed `X/X.rs` to `X/mod.rs,` as is now recommended style, for `std::num` and `std::terminfo`. - Shifted `src/libstd/str/ascii.rs` out of the otherwise unused `str` directory, to be consistent with its import path of `std::ascii`; libstd is flat at present so it's more appropriate thus. While this removes some `#[path = "..."]` directives, it does not remove all of them, and leaves certain other inconsistencies, such as `std::u8` et al. which are actually stored in `src/libstd/num/` (one subdirectory down). No quorum has been reached on this issue, so I felt it best to leave them all alone at present. #9208 deals with the possibility of making libstd more hierarchical (such as changing the crate to match the current filesystem structure, which would make the module path `std::num::u8`). There is one thing remaining in which this repository is not rustpkg-compliant: rustpkg would have `src/std/` et al. rather than `src/libstd/` et al. I have not endeavoured to change that at this point as it would guarantee prompt bitrot and confusion. A change of that magnitude needs to be discussed first.
+1, with @blake2-ppc's idea. |
It was decided in today's meeting that we are in favor of moving in this direction, but it is difficult to say "yes" or "no" in a general context without a concrete proposal. One specific thing that we dislike today is |
Proposal:
|
This has essentially happened with the splitting up of the various crates. I think the conversation here is too out-of-date to still be relevant, although similar changes could be proposed for other parts of the standard library. |
Rust has a module system and so it seems like a waste to just export everything as
std::foo
andextra::foo
:grep '^pub mod' | wc -l
counts 53 and 50 direct exports respectively.Low hanging fruit would be moving
std::{i8,uint,f32, ...}
tostd::num::*
.Other possibilities (off the top of my head):
std
:ascii
,c_str
tostr::*
or evenascii
,c_str
,to_str
,from_str
,str
,fmt
tostd::text::*
(or anything in between)hashmap
,trie
,vec
,at_vec
tocontainer::*
at_vec
tovec::at_vec
(orcontainer
as above)ptr
,owned
,managed
,borrow
toptr::*
(with the currentptr
becomingptr::raw
.)extra
:bigint
,rational
,complex
tonum::*
dlist
,list
,ringbuf
,smallintmap
,priority_queue
,treemap
tocontainer::*
sha1
,sha2
,md5
,md4
tocrypto::*
(or something, I'd feel bad about puttingmd5
/md4
in "crypto")(I imagine it'd be very easy to get carried away with making it too granular.)
The text was updated successfully, but these errors were encountered: