Closed
Description
Rust has a module system and so it seems like a waste to just export everything as std::foo
and extra::foo
: grep '^pub mod' | wc -l
counts 53 and 50 direct exports respectively.
Low hanging fruit would be moving std::{i8,uint,f32, ...}
to std::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.)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
huonw commentedon Sep 15, 2013
Nominating for backwards compatible.
Kimundi commentedon Sep 15, 2013
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.
std::text
seems like a general enough module name, encodings can also live in there.Using modules would also mean the source files could get properly grouped in directories without needing the
#[path = "..."]
attribute to make rustc find them.sfackler commentedon Sep 15, 2013
There was some discussion of reorganizing the various encoding modules in
extra
at #8310.alexcrichton commentedon Sep 15, 2013
One thing we'd want to watch out for is making common types difficult to access, having to type
use std::containers::hashmap::HashMap
is a lot of characters just to get a normal hash map in scope.I'm all for reorganization though if it collects things together nicely.
bluss commentedon Sep 15, 2013
modules like
hashmap
,trie
andextra::treemap
don't seem to have any toplevelpub fn
or other items that are commonly accessed(?). Maybe the types can be imported so they are all available understd::container::{HashMap, HashSet, TrieMap, TreeMap}
(is this too inconsistent?)alexcrichton commentedon Sep 15, 2013
+1 to that, that would be awesome.
catamorphism commentedon Sep 19, 2013
accepted backwards-compatible (we're not committing to doing this; just, the decision is on milestone 2)
Rename files to match current recommendations.
auto merge of #10143 : chris-morgan/rust/filename-consistency, r=huonw
emberian commentedon Dec 15, 2013
+1, with @blake2-ppc's idea.
alexcrichton commentedon Dec 17, 2013
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
std::rc::Rc
,std::hashmap::HashMap
and how you always repeat yourself when importing types. It was brought up that some crates in servo solve this through re-exports.huonw commentedon Dec 18, 2013
Proposal:
std
Moved
text
ascii
c_str
char
str
fmt
to_str
,from_str
send_str
num
u8
,u16
etc.cmath
ptr
rc::Rc
,gc::Gc
rc
raw
owned
borrowed
managed
(irrelevant when@
gets removed)gc
container
HashMap
,HashSet
,Trie
, etc.)hashmap
trie
vec
at_vec
(irrelevant when@[]
gets removed)Unchanged
any
bool
cast
cmp
condition
hash
io
iter
libc
mem
os
path
prelude
rand
reflect
repr
rt
run
to_bytes
util
(slated for removal, anyway?)Unsure
comm
,local_data
andtask
could be cometask::{comm, local_data}
, orconcurrent::{comm, local_data, task}
(with appropriate re-exports)cell
,option
,result
,either
are all "containers" of some sort, they could be placed incontainer
, or also just left unchanged.extra
This may be infeasible, if we end up splitting
extra
, although it might create good lines along which to split it.Moved
num
bigint
complex
rational
container
bitv
btree
c_vec
dlist
enum_set
list
lru_cache
priority_queue
ringbuf
smallintmap
treemap
encoding
(I'm personally not keen on this name, and not 100% sure that this division is reasonable)serialize
json
ebml
base64
hex
term
terminfo
concurrent
Arc
,MutexArc
,RWArc
,Future
arc
future
sync
task_pool
Unchanged
arena
flate
getopts
glob
semver
stats
tempfile
time
url
uuid
workcache
Removed
sort
, should just be one or two functions invec
(add a fast O(n log n) stable sort without Clone to std::vec #9819)thestinger commentedon Mar 23, 2014
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.