about summary refs log tree commit diff
path: root/src/libcollectionstest
AgeCommit message (Collapse)AuthorLines
2016-10-11Rollup merge of #36699 - bluss:repeat-str, r=alexcrichtonGuillaume Gomez-0/+8
Add method str::repeat(self, usize) -> String It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
2016-10-11Add Vec::dedup_by and Vec::dedup_by_keySimon Sapin-0/+27
2016-10-11Add method str::repeat(self, usize) -> StringUlrik Sverdrup-0/+8
It is relatively simple to repeat a string n times: `(0..n).map(|_| s).collect::<String>()`. It becomes slightly more complicated to do it “right” (sizing the allocation up front), which warrants a method that does it for us. This method is useful in writing testcases, or when generating text. `format!()` can be used to repeat single characters, but not repeating strings like this.
2016-10-03Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturonbors-2/+6
std: Stabilize and deprecate APIs for 1.13 This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-10-03std: Stabilize and deprecate APIs for 1.13Alex Crichton-2/+6
This commit is intended to be backported to the 1.13 branch, and works with the following APIs: Stabilized * `i32::checked_abs` * `i32::wrapping_abs` * `i32::overflowing_abs` * `RefCell::try_borrow` * `RefCell::try_borrow_mut` * `DefaultHasher` * `DefaultHasher::new` * `DefaultHasher::default` Deprecated * `BinaryHeap::push_pop` * `BinaryHeap::replace` * `SipHash13` * `SipHash24` * `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map` module Closes #28147 Closes #34767 Closes #35057 Closes #35070
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+1
2016-09-29Auto merge of #36430 - llogiq:cow_add, r=alexcrichtonbors-0/+65
impl Add<{str, Cow<str>}> for Cow<str> cc #35837
2016-09-29impl {Add, AddAssign}<{str, Cow<str>}> for Cow<str>Andre Bogus-0/+65
This does not actually add anything that wasn't there, but is merely an optimization for the given cases, which would have incurred additional heap allocation for adding empty strings, and improving the ergonomics of `Cow` with strings.
2016-09-28[breaking-change] std: change `encode_utf{8,16}()` to take a buffer and ↵tormol-4/+4
return a slice They panic if the buffer is too small.
2016-09-26Move Vec::dedup tests from slice.rs to vec.rsSimon Sapin-29/+29
2016-09-26Remove duplicate test.Simon Sapin-12/+0
test_dedup_shared has been exactly the same as test_dedup_unique since 6f16df4aa, three years ago.
2016-09-13Add tests for str::replacenknight42-0/+15
2016-08-28Address FIXME in libcollectionstest/btree/set.rsAndrew Paseltiner-25/+6
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-3/+0
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-17Auto merge of #35747 - jonathandturner:rollup, r=jonathandturnerbors-0/+8
Rollup of 23 pull requests - Successful merges: #34370, #35415, #35595, #35610, #35613, #35614, #35621, #35660, #35663, #35670, #35671, #35672, #35681, #35686, #35690, #35695, #35707, #35708, #35713, #35722, #35725, #35726, #35731 - Failed merges: #35395
2016-08-17Auto merge of #35733 - apasel422:issue-35721, r=alexcrichtonbors-1/+2
Make `vec::IntoIter` covariant again Closes #35721 r? @alexcrichton
2016-08-17Rollup merge of #35707 - frewsxcv:vec-into-iter-debug, r=alexcrichtonJonathan Turner-0/+8
Implement `Debug` for `std::vec::IntoIter`. Display all the remaining items of the iterator, similar to the `Debug` implementation for `core::slice::Iter`: https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937 Using the `as_slice` method that was added in: https://github.com/rust-lang/rust/pull/35447
2016-08-16Auto merge of #35559 - frewsxcv:slice-iter-as-ref, r=alexcrichtonbors-0/+18
Implement `AsRef<[T]>` for `std::slice::Iter`. `AsRef` is designed for conversions that are "cheap" (as per the API docs). It is the case that retrieving the underlying data of `std::slice::Iter` is cheap. In my opinion, there's no ambiguity about what slice data will be returned, otherwise, I would be more cautious about implementing `AsRef`.
2016-08-16Make `vec::IntoIter` covariant againAndrew Paseltiner-1/+2
Closes #35721
2016-08-16Auto merge of #35354 - tomgarcia:covariant-drain, r=alexcrichtonbors-0/+6
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant Fixed the rest of the Drain iterators.
2016-08-16Add basic unit test for `std::slice::Iter::as_slice`.Corey Farwell-0/+9
2016-08-16Implement `AsRef<[T]>` for `std::slice::Iter`.Corey Farwell-0/+9
`AsRef` is designed for conversions that are "cheap" (as per the API docs). It is the case that retrieving the underlying data of `std::slice::Iter` is cheap. In my opinion, there's no ambiguity about what slice data will be returned, otherwise, I would be more cautious about implementing `AsRef`.
2016-08-15Implement `Debug` for `std::vec::IntoIter`.Corey Farwell-0/+8
Display all the remaining items of the iterator, similar to the `Debug` implementation for `core::slice::Iter`: https://github.com/rust-lang/rust/blob/f0bab98695f0a4877daabad9a5b0ba3e66121392/src/libcore/slice.rs#L930-L937 Using the `as_slice` method that was added in: https://github.com/rust-lang/rust/pull/35447
2016-08-11Introduce `as_mut_slice` method on `std::vec::IntoIter` struct.Corey Farwell-0/+11
2016-08-11Introduce `as_slice` method on `std::vec::IntoIter` struct.Corey Farwell-0/+13
Similar to the `as_slice` method on `core::slice::Iter` struct.
2016-08-04Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariantThomas Garcia-0/+6
2016-07-30Rollup merge of #35049 - knight42:add-test, r=alexcrichtonManish Goregaokar-0/+11
Add a test for AddAssign on String Fix #35047
2016-07-28Auto merge of #34485 - tbu-:pr_unicode_debug_str, r=alexcrichtonbors-2/+18
Escape fewer Unicode codepoints in `Debug` impl of `str` Use the same procedure as Python to determine whether a character is printable, described in [PEP 3138]. In particular, this means that the following character classes are escaped: - Cc (Other, Control) - Cf (Other, Format) - Cs (Other, Surrogate), even though they can't appear in Rust strings - Co (Other, Private Use) - Cn (Other, Not Assigned) - Zl (Separator, Line) - Zp (Separator, Paragraph) - Zs (Separator, Space), except for the ASCII space `' '` `0x20` This allows for user-friendly inspection of strings that are not English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`). Fixes #34318. CC #34422. [PEP 3138]: https://www.python.org/dev/peps/pep-3138/
2016-07-28Rename `char::escape` to `char::escape_debug` and add tracking issueTobias Bucher-11/+11
2016-07-28Add test for string AddAssignKnight-0/+11
2016-07-26Restore `char::escape_default` and add `char::escape` insteadTobias Bucher-1/+15
2016-07-23Escape fewer Unicode codepoints in `Debug` impl of `str`Tobias Bucher-4/+6
Use the same procedure as Python to determine whether a character is printable, described in [PEP 3138]. In particular, this means that the following character classes are escaped: - Cc (Other, Control) - Cf (Other, Format) - Cs (Other, Surrogate), even though they can't appear in Rust strings - Co (Other, Private Use) - Cn (Other, Not Assigned) - Zl (Separator, Line) - Zp (Separator, Paragraph) - Zs (Separator, Space), except for the ASCII space `' '` (`0x20`) This allows for user-friendly inspection of strings that are not English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`). Fixes #34318. [PEP 3138]: https://www.python.org/dev/peps/pep-3138/
2016-07-21Readding lifetime parameters and removing allocationThomas Garcia-2/+2
2016-07-21Make vec::Drain and binary_heap::Drain covariantThomas Garcia-0/+12
2016-07-03std: Stabilize APIs for the 1.11.0 releaseAlex Crichton-4/+0
Although the set of APIs being stabilized this release is relatively small, the trains keep going! Listed below are the APIs in the standard library which have either transitioned from unstable to stable or those from unstable to deprecated. Stable * `BTreeMap::{append, split_off}` * `BTreeSet::{append, split_off}` * `Cell::get_mut` * `RefCell::get_mut` * `BinaryHeap::append` * `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past libstd stabilizations * `Iterator::sum` * `Iterator::product` Deprecated * `{f32, f64}::next_after` * `{f32, f64}::integer_decode` * `{f32, f64}::ldexp` * `{f32, f64}::frexp` * `num::One` * `num::Zero` Added APIs (all unstable) * `iter::Sum` * `iter::Product` * `iter::Step` - a few methods were added to accomodate deprecation of One/Zero Removed APIs * `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is unstable Closes #27739 Closes #27752 Closes #32526 Closes #33444 Closes #34152 cc #34529 (new tracking issue)
2016-06-21implemented peek_mut and unit testsNathan Moos-0/+19
2016-06-09clean up for test casesSrinivas Reddy Thatiparthy-14/+14
2016-06-09remove redundant assert statementsSrinivas Reddy Thatiparthy-2/+0
2016-06-01Auto merge of #33947 - xosmig:btree_split_off, r=gereeterbors-0/+127
Implement split_off for BTreeMap and BTreeSet (RFC 509) Fixes #19986 and refactors common with append methods. It splits the tree with O(log n) operations and then calculates sizes by traversing the lower one. CC @gereeter
2016-06-01Implement split_off for BTreeMap and BTreeSet (RFC 509)Andrey Tonkih-0/+127
2016-05-30std: Clean out old unstable + deprecated APIsAlex Crichton-59/+0
These should all have been deprecated for at least one cycle, so this commit cleans them all out.
2016-05-27Auto merge of #33795 - srinivasreddy:lib_coll_test, r=nrcbors-405/+442
run rustfmt on libcollections test module
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-2/+0
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-24format with [rustfmt_skip] and addressed a few commentsSrinivas Reddy Thatiparthy-80/+19
2016-05-22run rustfmt on libcollections test moduleSrinivas Reddy Thatiparthy-424/+522
2016-05-09Utilize `Result::unwrap_err` in more places.Corey Farwell-1/+1
2016-04-22Implement `append` for b-trees.Johannes Oertel-0/+77
The algorithm implemented here is linear in the size of the two b-trees. It firsts creates a `MergeIter` from the two b-trees and then builds a new b-tree by pushing key-value pairs from the `MergeIter` into nodes at the right heights. Three functions for stealing have been added to the implementation of `Handle` as well as a getter for the height of a `NodeRef`. The docs have been updated with performance information about `BTreeMap::append` and the remark about B has been removed now that it is the same for all instances of `BTreeMap`.
2016-04-20Auto merge of #32951 - LukasKalbertodt:collection_contains_rfc1552, r=brsonbors-0/+28
Add `contains` to `VecDeque` and `LinkedList` (+ tests) This implements [RFC 1552](https://github.com/rust-lang/rfcs/blob/master/text/1552-contains-method-for-various-collections.md). Tracking issue: #32630 Sorry for the late response. This is my first contribution, so please tell me if anything isn't optimal!
2016-04-17Auto merge of #32987 - xosmig:binary_heap_extension, r=apasel422bors-0/+33
collections: add append for binary heap
2016-04-16Auto merge of #32977 - alexcrichton:ignore-panics, r=brsonbors-1/+1
std: Change String::truncate to panic less The `Vec::truncate` method does not panic if the length argument is greater than the vector's current length, but `String::truncate` will indeed panic. This semantic difference can be a bit jarring (e.g. #32717), and after some discussion the libs team concluded that although this can technically be a breaking change it is almost undoubtedly not so in practice. This commit changes the semantics of `String::truncate` to be a noop if `new_len` is greater than the length of the current string. Closes #32717