diff options
| author | bors <bors@rust-lang.org> | 2014-07-23 21:41:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-23 21:41:14 +0000 |
| commit | fb72c4767fa423649feeb197b50385c1fa0a6fd5 (patch) | |
| tree | 85beee9373b61bc02cc53b94d11fe128e9ab2f1b /src/libstd | |
| parent | b3a732a3eab60862068b1006973de5924bcda9e2 (diff) | |
| parent | 71a75cc2ce6d6eed2557e6c585e81abcdad86827 (diff) | |
| download | rust-fb72c4767fa423649feeb197b50385c1fa0a6fd5.tar.gz rust-fb72c4767fa423649feeb197b50385c1fa0a6fd5.zip | |
auto merge of #15611 : brson/rust/pushpop, r=alexcrichton
This fixes naming conventions for `push`/`pop` from either end of a structure by partially implementing @erickt's suggestion from https://github.com/rust-lang/rust/issues/10852#issuecomment-30823343, namely: * push/pop from the 'back' are called `push` and `pop`. * push/pop from the 'front' are called `push_front` and `pop_front`. * `push`/`pop` are declared on the `MutableSeq` trait. * Implement `MutableSeq` for `Vec`, `DList`, and `RingBuf`. * Add `MutableSeq` to the prelude. I did not make any further refactorings because there is some more extensive thought that needs to be put into the collections traits. This is an easy first step that should close https://github.com/rust-lang/rust/issues/10852. I left the `push_back` and `pop_back` methods on `DList` and `RingBuf` deprecated. Because `MutableSeq` is in the prelude it shouldn't break many, but it is a breaking change.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hashmap.rs | 2 | ||||
| -rw-r--r-- | src/libstd/collections/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/fs.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/net/tcp.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/signal.rs | 1 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 2 | ||||
| -rw-r--r-- | src/libstd/os.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path/posix.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 2 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 2 |
14 files changed, 15 insertions, 10 deletions
diff --git a/src/libstd/collections/hashmap.rs b/src/libstd/collections/hashmap.rs index a05fad3705d..922858e963c 100644 --- a/src/libstd/collections/hashmap.rs +++ b/src/libstd/collections/hashmap.rs @@ -1291,7 +1291,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { /// // new value based on the first letter of the key. /// |key, already, new| { /// if key.as_slice().starts_with("z") { - /// already.unshift(new); + /// already.insert(0, new); /// } else { /// already.push(new); /// } diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index ccef1c0fd2a..d98d490a84b 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -15,7 +15,7 @@ #![experimental] pub use core_collections::{Collection, Mutable, Map, MutableMap}; -pub use core_collections::{Set, MutableSet, Deque}; +pub use core_collections::{Set, MutableSet, Deque, MutableSeq}; pub use core_collections::{Bitv, BitvSet, BTree, DList, EnumSet}; pub use core_collections::{PriorityQueue, RingBuf, SmallIntMap}; pub use core_collections::{TreeMap, TreeSet, TrieMap, TrieSet}; diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 86283f03381..5980245fa79 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -20,6 +20,7 @@ A simple wrapper over the platform's dynamic library facilities #![allow(missing_doc)] use clone::Clone; +use collections::MutableSeq; use c_str::ToCStr; use iter::Iterator; use mem; diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index ca3eee01575..5215aec5dfb 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -15,7 +15,7 @@ // FIXME: Not sure how this should be structured // FIXME: Iteration should probably be considered separately -use collections::Collection; +use collections::{Collection, MutableSeq}; use iter::Iterator; use option::{Option, Some, None}; use result::{Ok, Err}; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index afd88ee0ed9..c7dec49a76d 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -53,7 +53,7 @@ fs::unlink(&path); use c_str::ToCStr; use clone::Clone; -use collections::Collection; +use collections::{Collection, MutableSeq}; use io::standard_error; use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader}; diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 642654ba6ed..cb754135bc1 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -18,6 +18,7 @@ //! listener (socket server) implements the `Listener` and `Acceptor` traits. use clone::Clone; +use collections::MutableSeq; use io::IoResult; use iter::Iterator; use slice::ImmutableVector; diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index d46f437cddd..c126866e715 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -20,6 +20,7 @@ definitions for a number of signals. */ use clone::Clone; +use collections::MutableSeq; use comm::{Sender, Receiver, channel}; use io; use iter::Iterator; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index e14092bc8dc..125c3fdf5d9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -288,4 +288,6 @@ mod std { #[cfg(test)] pub use os = realstd::os; // The test runner requires std::slice::Vector, so re-export std::slice just for it. #[cfg(test)] pub use slice; + + pub use collections; // vec!() uses MutableSeq } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index cc30acf064b..c8528e752e8 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -14,7 +14,7 @@ use char; use clone::Clone; -use collections::Collection; +use collections::{Collection, MutableSeq}; use num::{NumCast, Zero, One, cast, Int}; use num::{Float, FPNaN, FPInfinite, ToPrimitive}; use num; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 96d3b3e3e6a..f71f1d22d00 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -32,7 +32,7 @@ #![allow(non_snake_case_functions)] use clone::Clone; -use collections::Collection; +use collections::{Collection, MutableSeq}; use fmt; use io::{IoResult, IoError}; use iter::Iterator; diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index ececfab5f74..0c93f8e6de9 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -65,7 +65,7 @@ println!("path exists: {}", path.exists()); #![experimental] -use collections::Collection; +use collections::{Collection, MutableSeq}; use c_str::CString; use clone::Clone; use fmt; diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 007686aa05c..877ca2c7e01 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -13,7 +13,7 @@ use c_str::{CString, ToCStr}; use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; -use collections::Collection; +use collections::{Collection, MutableSeq}; use from_str::FromStr; use hash; use io::Writer; diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 4a6ed561233..d9b802b38fd 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -16,7 +16,7 @@ use ascii::AsciiCast; use c_str::{CString, ToCStr}; use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; -use collections::Collection; +use collections::{Collection, MutableSeq}; use from_str::FromStr; use hash; use io::Writer; diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 0fa223305a6..0ce7497cf30 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -63,7 +63,7 @@ #[doc(no_inline)] pub use clone::Clone; #[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; #[doc(no_inline)] pub use cmp::{Ordering, Less, Equal, Greater, Equiv}; -#[doc(no_inline)] pub use collections::{Collection, Mutable, Map, MutableMap}; +#[doc(no_inline)] pub use collections::{Collection, Mutable, Map, MutableMap, MutableSeq}; #[doc(no_inline)] pub use collections::{Set, MutableSet}; #[doc(no_inline)] pub use iter::{FromIterator, Extendable, ExactSize}; #[doc(no_inline)] pub use iter::{Iterator, DoubleEndedIterator}; |
