about summary refs log tree commit diff
path: root/src/libcollections
AgeCommit message (Collapse)AuthorLines
2017-03-15Fix documentation for Vec::dedup_by.Kevin Mehall-1/+5
The previous docstring was copied from dedup_by_key.
2017-03-15Change how the `0` flag works in format!Piotr Jawniak-0/+4
Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits. :05 :<05 :>05 :^05 before |-0001| |-1000| |-0001| |-0100| after |-0001| |-0001| |-0001| |-0001| :#05x :<#05x :>#05x :^#05x before |0x001| |0x100| |000x1| |0x010| after |0x001| |0x001| |0x001| |0x001| Fixes #39997 [breaking-change]
2017-03-15Auto merge of #40009 - clarcharr:box_to_buf, r=alexcrichtonbors-0/+32
Leftovers from #39594; From<Box> impls These are a few more impls that follow the same reasoning as those from #39594. What's included: * `From<Box<str>> for String` * `From<Box<[T]>> for Vec<T>` * `From<Box<CStr>> for CString` * `From<Box<OsStr>> for OsString` * `From<Box<Path>> for PathBuf` * `Into<Box<str>> for String` * `Into<Box<[T]>> for Vec<T>` * `Into<Box<CStr>> for CString` * `Into<Box<OsStr>> for OsString` * `Into<Box<Path>> for PathBuf` * `<Box<CStr>>::into_c_string` * `<Box<OsStr>>::into_os_string` * `<Box<Path>>::into_path_buf` * Tracking issue for latter three methods + three from previous PR. Currently, the opposite direction isn't doable with `From` (only `Into`) because of the separation between `liballoc` and `libcollections`. I'm holding off on those for a later PR.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-115/+115
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13fix format grammarAndre Bogus-1/+2
2017-03-10Rollup merge of #40423 - DirkyJerky:patch-2, r=BurntSushiAlex Crichton-1/+1
Clarify docs in `VecDeque::resize`
2017-03-10Rollup merge of #40389 - F001:placementVecDeque, r=nagisaAlex Crichton-25/+160
Implement placement-in protocol for `VecDeque` CC #30172 r? @nagisa
2017-03-10Add From<Box<..>> implementations.Clar Charr-0/+32
2017-03-10Clarify docs in `VecDeque::resize`Geoff Yoerger-1/+1
2017-03-09Implement placement-in protocol for and `VecDeque`Charlie Fan-25/+160
2017-03-08Rollup merge of #40335 - tbu-:pr_doc_str_to_somecase, r=steveklabnikAriel Ben-Yehuda-0/+8
Document why `str.to_{lower,upper}case` return `String` Fixes #39201.
2017-03-08Rollup merge of #40325 - eddyb:pr38143, r=alexcrichtonAriel Ben-Yehuda-0/+21
Added remove_from to vec.rs (#38143) Turns out that if you push to someone's PR branch and cause the PR to close, you lose delegation šŸ˜ž. @madseagames I'm really sorry about that 😭
2017-03-08Document why `str.to_{lower,upper}case` return `String`Tobias Bucher-0/+8
Fixes #39201.
2017-03-07Added remove_from to vec.rsmadseagames-0/+21
2017-03-05Issue #39688 - Help people find String::as_bytes() for UTF-8 r? @steveklabnikJoshua Horwitz-0/+8
2017-03-03Auto merge of #40189 - SimonSapin:one-width, r=alexcrichtonbors-2/+3
Reduce std_unicode’s public API * Only keep one copy of the `UTF8_CHAR_WIDTH` table instead of one of each of libcore and libstd_unicode. * Move the `utf8_char_width` function to `core::str` under the `str_internals` unstable feature. * Remove `std_unicode::str::is_utf16`. It was only accessible through the `#[unstable]` crate std_unicode. It has never been used in the compiler or standard library since 47e7a05 added it in 2012 ā€œfor OS API interopā€. It can be replaced with a one-liner: ```rust fn is_utf16(slice: &[u16]) -> bool { std::char::decode_utf16(s).all(|r| r.is_ok()) } ```
2017-03-02Rollup merge of #40117 - SimonSapin:to-err-is-for-the-formatter, r=alexcrichtonCorey Farwell-2/+16
Panic on errors in `format!` or `<T: Display>::to_string` … instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes #40103
2017-03-01Panic on errors in `format!` or `<T: Display>::to_string`Simon Sapin-2/+16
… instead of silently ignoring a result. `fmt::Write for String` never returns `Err`, so implementations of `Display` (or other traits of that family) never should either. Fixes #40103
2017-03-01Only keep one copy of the UTF8_CHAR_WIDTH table.Simon Sapin-2/+3
… instead of one of each of libcore and libstd_unicode. Move the `utf8_char_width` function to `core::str` under the `str_internals` unstable feature.
2017-02-28Rollup merge of #40028 - withoutboats:string_from_iter, r=alexcrichtonCorey Farwell-0/+9
impl FromIterator<&char> for String
2017-02-28Rollup merge of #39936 - djzin:inclusive_rangeargument, r=alexcrichtonCorey Farwell-1/+27
impl RangeArgument for RangeInclusive and add appropriate tests Now that `RangeArgument` returns a `Bound`, the impl for `RangeInclusive` is natural to implement and all that's required are tests around it.
2017-02-26Auto merge of #39738 - keeperofdakeys:vec-docs, r=GuillaumeGomezbors-0/+9
Add notes about capacity effects to Vec::truncate() Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.
2017-02-24Rollup merge of #40048 - jimblandy:fmt-arg-types-doc, r=alexcrichtonGuillaume Gomez-21/+4
Update std::fmt module docs for landing of #33642. Since #33642, it's no longer true that all references to a given format argument must use the same type. The docs don't seem to have been updated.
2017-02-24Rollup merge of #39886 - mbrubeck:doc-edit, r=steveklabnikGuillaume Gomez-0/+44
Additional docs for Vec, String, and slice trait impls r? @steveklabnik
2017-02-22Update std::fmt module docs for landing of #33642.Jim Blandy-21/+4
2017-02-22impl FromIter<&char> for StringWithout Boats-0/+9
2017-02-18add impl for RangeToInclusiveDjzin-1/+11
2017-02-18impl RangeArgument for RangeInclusive and add appropriate testsDjzin-1/+17
2017-02-16Fixup String::split_off documentationSteven Allen-9/+9
1. Clarify that `String::split_off` returns one string and modifies self in-place. The documentation implied that it returns two new strings. 2. Make the documentation mirror `Vec::split_off`.
2017-02-16Additional docs for Vec, String, and slice trait implsMatt Brubeck-0/+44
2017-02-15Rollup merge of #39836 - durka:patch-37, r=alexcrichtonCorey Farwell-4/+4
fix types in to_owned doctest Fixes #39831.
2017-02-15Auto merge of #39457 - bvinc:master, r=alexcrichtonbors-115/+92
Dont segfault if btree range is not in order This is a first attempt to fix issue #33197. The issue is that the BTree iterator uses next_unchecked for fast iteration, but it can be tricked into running off the end of the tree and segfaulting if range is called with a maximum that is less than the minimum. Since a user defined Ord should not determine the safety of BTreeMap, and we still want fast iteration, I've implemented the idea of @gereeter and walk the tree simultaneously searching for both keys to make sure that if our keys diverge, the min key is to the left of our max key. I currently panic if that is not the case. Open questions: 1. Do we want to panic in this error case or do we want to return an empty iterator? The drain API panics if the range is bad, but drain is given a range of index values, while this is a generic key type. Panicking is brittle and returning an empty iterator is probably the most flexible and matches what people would want it to do... but artificially returning a BTreeMap::Range with start==end seems like a pretty weird and unnatural thing to do, although it's doable since those fields are not accessible. The same question for other weird cases: 2. (Included(101), Excluded(100)) on a map that contains [1,2,3]. Both BTree edges end up on the same part of the map, but comparing the keys shows the range is backwards. 3. (Excluded(5), Excluded(5)). The keys are equal but BTree edges end up backwards if the map contains 5. 4. (Included(5), Excluded(5)). Should naturally produce an empty iterator, right?
2017-02-14fix types in to_owned doctestAlex Burka-4/+4
2017-02-14Add notes about capacity effects to Vec::truncate()Josh-0/+9
2017-02-13typo fixking6cong-1/+1
2017-02-10Rollup merge of #39701 - sgrif:sg-vec-reserve-docs, r=alexcrichtonCorey Farwell-3/+6
Explicitly mention that `Vec::reserve` is based on len not capacity I spent a good chunk of time tracking down a buffer overrun bug that resulted from me mistakenly thinking that `reserve` was based on the current capacity not the current length. It would be helpful if this were called out explicitly in the docs.
2017-02-10Dont segfault if btree range is not in orderBrian Vincent-115/+92
2017-02-09Update set operations documentationJethro Beekman-7/+17
Reminding people of set terminology.
2017-02-09Explicitly mention that `Vec::reserve` is based on len not capacitySean Griffin-3/+6
I spent a good chunk of time tracking down a buffer overrun bug that resulted from me mistakenly thinking that `reserve` was based on the current capacity not the current length. It would be helpful if this were called out explicitly in the docs.
2017-02-08Rollup merge of #39561 - phungleson:libcollectionsbench, r=alexcrichtonCorey Farwell-4/+1543
Extract collections benchmarks to libcollections/bench Good suggestion from @stjepang https://github.com/rust-lang/rust/issues/39484#issuecomment-277467765 r? @alexcrichton
2017-02-07Auto merge of #39002 - GuillaumeGomez:debug_libcollections, r=aturonbors-0/+257
Add Debug implementations for libcollection structs Part of #31869.
2017-02-06Extract collections benchmarks to libcollections/benchesSon-4/+1543
And libcore/benches
2017-02-05Rollup merge of #39538 - stjepang:slightly-optimize-sort, r=alexcrichtonCorey Farwell-32/+36
Slightly optimize slice::sort First, get rid of some bound checks. Second, instead of comparing by ternary `compare` function, use a binary function testing whether an element is less than some other element. This apparently makes it easier for the compiler to reason about the code. I've noticed the same effect with [pdqsort](https://github.com/stjepang/pdqsort) crate. Benchmark: ``` name before ns/iter after ns/iter diff ns/iter diff % slice::bench::sort_large_ascending 8,969 (8919 MB/s) 7,410 (10796 MB/s) -1,559 -17.38% slice::bench::sort_large_big_ascending 355,640 (3599 MB/s) 359,137 (3564 MB/s) 3,497 0.98% slice::bench::sort_large_big_descending 427,112 (2996 MB/s) 424,721 (3013 MB/s) -2,391 -0.56% slice::bench::sort_large_big_random 2,207,799 (579 MB/s) 2,138,804 (598 MB/s) -68,995 -3.13% slice::bench::sort_large_descending 13,694 (5841 MB/s) 13,514 (5919 MB/s) -180 -1.31% slice::bench::sort_large_mostly_ascending 239,697 (333 MB/s) 203,542 (393 MB/s) -36,155 -15.08% slice::bench::sort_large_mostly_descending 270,102 (296 MB/s) 234,263 (341 MB/s) -35,839 -13.27% slice::bench::sort_large_random 513,406 (155 MB/s) 470,084 (170 MB/s) -43,322 -8.44% slice::bench::sort_large_random_expensive 23,650,321 (3 MB/s) 23,675,098 (3 MB/s) 24,777 0.10% slice::bench::sort_medium_ascending 143 (5594 MB/s) 132 (6060 MB/s) -11 -7.69% slice::bench::sort_medium_descending 197 (4060 MB/s) 188 (4255 MB/s) -9 -4.57% slice::bench::sort_medium_random 3,358 (238 MB/s) 3,271 (244 MB/s) -87 -2.59% slice::bench::sort_small_ascending 32 (2500 MB/s) 32 (2500 MB/s) 0 0.00% slice::bench::sort_small_big_ascending 97 (13195 MB/s) 97 (13195 MB/s) 0 0.00% slice::bench::sort_small_big_descending 247 (5182 MB/s) 249 (5140 MB/s) 2 0.81% slice::bench::sort_small_big_random 502 (2549 MB/s) 498 (2570 MB/s) -4 -0.80% slice::bench::sort_small_descending 55 (1454 MB/s) 61 (1311 MB/s) 6 10.91% slice::bench::sort_small_random 358 (223 MB/s) 356 (224 MB/s) -2 -0.56% ```
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-2/+2
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-05Replace PlaceBack Debug implementation with deriveGuillaume Gomez-94/+59
2017-02-04Slightly optimize slice::sortStjepan Glavina-32/+36
First, get rid of some bound checks. Second, instead of comparing by ternary `compare` function, use a binary function testing whether an element is less than some other element. This apparently makes it easier for the compiler to reason about the code. Benchmark: ``` name before ns/iter after ns/iter diff ns/iter diff % slice::bench::sort_large_ascending 8,969 (8919 MB/s) 7,410 (10796 MB/s) -1,559 -17.38% slice::bench::sort_large_big_ascending 355,640 (3599 MB/s) 359,137 (3564 MB/s) 3,497 0.98% slice::bench::sort_large_big_descending 427,112 (2996 MB/s) 424,721 (3013 MB/s) -2,391 -0.56% slice::bench::sort_large_big_random 2,207,799 (579 MB/s) 2,138,804 (598 MB/s) -68,995 -3.13% slice::bench::sort_large_descending 13,694 (5841 MB/s) 13,514 (5919 MB/s) -180 -1.31% slice::bench::sort_large_mostly_ascending 239,697 (333 MB/s) 203,542 (393 MB/s) -36,155 -15.08% slice::bench::sort_large_mostly_descending 270,102 (296 MB/s) 234,263 (341 MB/s) -35,839 -13.27% slice::bench::sort_large_random 513,406 (155 MB/s) 470,084 (170 MB/s) -43,322 -8.44% slice::bench::sort_large_random_expensive 23,650,321 (3 MB/s) 23,675,098 (3 MB/s) 24,777 0.10% slice::bench::sort_medium_ascending 143 (5594 MB/s) 132 (6060 MB/s) -11 -7.69% slice::bench::sort_medium_descending 197 (4060 MB/s) 188 (4255 MB/s) -9 -4.57% slice::bench::sort_medium_random 3,358 (238 MB/s) 3,271 (244 MB/s) -87 -2.59% slice::bench::sort_small_ascending 32 (2500 MB/s) 32 (2500 MB/s) 0 0.00% slice::bench::sort_small_big_ascending 97 (13195 MB/s) 97 (13195 MB/s) 0 0.00% slice::bench::sort_small_big_descending 247 (5182 MB/s) 249 (5140 MB/s) 2 0.81% slice::bench::sort_small_big_random 502 (2549 MB/s) 498 (2570 MB/s) -4 -0.80% slice::bench::sort_small_descending 55 (1454 MB/s) 61 (1311 MB/s) 6 10.91% slice::bench::sort_small_random 358 (223 MB/s) 356 (224 MB/s) -2 -0.56% ```
2017-02-04Auto merge of #39440 - F001:SpecializeCow, r=blussbors-0/+16
std: Add ToString trait specialization for Cow<'a, str> and String There is a specialized version of ToString for str type in std. I think there are other types can also benefit from specialization. `Cow` and `String` are the most obvious one. r? @bluss
2017-02-03Merge remote-tracking branch 'upstream/master' into format-with-capacityMichał Krasnoborski-69/+88
2017-02-03Auto merge of #39466 - alexcrichton:fix, r=Manishearthbors-1/+1
std: Fix IntoIter::as_mut_slice's signature This was intended to require `&mut self`, not `&self`, otherwise it's unsound! Closes #39465
2017-02-02std: Fix IntoIter::as_mut_slice's signatureAlex Crichton-1/+1
This was intended to require `&mut self`, not `&self`, otherwise it's unsound! Closes #39465