Commit Graph

87 Commits

Author SHA1 Message Date
Alexander Regueiro 99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Mazdak Farrokhzad 2396780cda liballoc: revert nested imports style changes. 2019-02-03 08:27:44 +01:00
Mazdak Farrokhzad 748970dfa9 liballoc: apply uniform_paths. 2019-02-02 11:05:20 +01:00
Mazdak Farrokhzad 3bfa0a35f6 liballoc: prefer imports of borrow from libcore. 2019-02-02 10:53:27 +01:00
Mazdak Farrokhzad f09f62f62c liballoc: adjust abolute imports + more import fixes. 2019-02-02 10:34:36 +01:00
Mazdak Farrokhzad 7693e3e666 liballoc: refactor & fix some imports. 2019-02-02 10:14:40 +01:00
Mazdak Farrokhzad e6e27924e1 liballoc: cargo check passes on 2018 2019-02-02 08:36:45 +01:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
bors 9cb38a84e7 Auto merge of #56463 - ljedrz:slice_concat_join, r=nikic
slice: tweak concat & join

- use `sum` instead of `fold` (readability)
- adjust the capacity for `join` - the number of separators is `n - 1`, not `n`; proof:
```
fn main() {
    let a = [[1, 2], [4, 5]];
    let v = a.join(&3);

    assert_ne!(v.len(), v.capacity()); // len is 5, capacity is 6
}
```
2018-12-09 22:39:44 +00:00
Alexander Regueiro ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
ljedrz ae53273021 slice: tweak concat & join 2018-12-03 16:22:27 +01:00
bors f3adec65dd Auto merge of #53918 - Havvy:doc-sort-by, r=GuillaumeGomez
Doc total order requirement of sort(_unstable)_by

I took the definition of what a total order is from the Ord trait
docs. I specifically put "elements of the slice" because if you
have a slice of f64s, but know none are NaN, then sorting by
partial ord is total in this case. I'm not sure if I should give
such an example in the docs or not.

r? @GuillaumeGomez
2018-11-22 06:50:18 +00:00
Sebastian Dröge 52cc6fde4b Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()
Fixes #55177
2018-10-18 18:51:56 +03:00
Sebastian Dröge b08ca2958e Stabilize slice::chunks_exact() and slice::chunks_exact_mut()
Fixes #47115
2018-10-18 18:51:56 +03:00
Sebastian Dröge 80a8e5c1f7 Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()
These work exactly like the normal chunks iterators but start creating
chunks from the end of the slice.

See #55177 for the tracking issue
2018-10-18 10:38:05 +03:00
Havvy (Ryan Scheel) 99bed21101 Linkify types in docs 2018-10-05 17:41:43 -07:00
Havvy (Ryan Scheel) b911dba40b Slice total example: Move closer to total defn 2018-10-05 17:41:43 -07:00
Havvy (Ryan Scheel) e36bbc82f2 Example of total ord of elements for sort_by 2018-10-05 17:41:42 -07:00
Havvy (Ryan Scheel) 7e57f0a6a8 Doc total order requirement of sort(_unstable)_by
I took the definition of what a total order is from the Ord trait
docs. I specifically put "elements of the slice" because if you
have a slice of f64s, but know none are NaN, then sorting by
partial ord is total in this case. I'm not sure if I should give
such an example in the docs or not.
2018-10-05 17:41:42 -07:00
Sebastian Dröge 068c92b2cc Also rename ExactChunks iterator name to ChunksExact 2018-09-25 08:56:48 +03:00
Sebastian Dröge e09e45041b Rename slice::exact_chunks() to slice::chunks_exact()
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815
and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-24 22:43:06 +03:00
Alex Crichton 8ac88d375e std: Check for overflow in str::repeat
This commit fixes a buffer overflow issue in the standard library
discovered by Scott McMurray where if a large number was passed to
`str::repeat` it may cause and out of bounds write to the buffer of a `Vec`.
This bug was accidentally introduced in #48657 when optimizing the
`str::repeat` function. The bug affects stable Rust releases 1.26.0 to
1.29.0. We plan on backporting this fix to create a 1.29.1 release, and
the 1.30.0 release onwards will include this fix.

The fix in this commit is to introduce a deterministic panic in the case of
capacity overflow. When repeating a slice where the resulting length is larger
than the address space, there’s no way it can succeed anyway!

The standard library and surrounding libraries were briefly checked to see if
there were othere instances of preallocating a vector with a calculation that
may overflow. No instances of this bug (out of bounds write due to a calculation
overflow) were found at this time.

Note that this commit is the first steps towards fixing this issue,
we'll be making a formal post to the Rust security list once these
commits have been merged.
2018-09-20 09:31:53 -07:00
Corey Farwell 993fb93464 Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
Mark Simulacrum 5a575b542d Rollup merge of #51147 - tmccombs:sliceindex, r=SimonSapin
Stabilize SliceIndex trait.

CC #35729

According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
2018-06-02 13:14:25 -06:00
Emerentius 12bd288746 incorporate changes from code review
further reduce unsafe fn calls
reduce right drift
assert! sufficient capacity
2018-06-01 17:13:26 +02:00
Emerentius d866082050 optimize joining and concatenation for slices
for both Vec<T> and String
- eliminates the boolean first flag in fn join()

for String only
- eliminates repeated bounds checks in join(), concat()
- adds fast paths for small string separators up to a len of 4 bytes
2018-06-01 17:13:24 +02:00
Thayne McCombs 9d770e9959 Stabilize SliceIndex trait.
Fixes #35729

According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
2018-06-01 00:04:26 -06:00
Stjepan Glavina 26d62f55a4 Stabilize feature from_ref 2018-05-21 18:16:08 +02:00
Mark Simulacrum 9e3432447a Switch to 1.26 bootstrap compiler 2018-05-17 08:47:25 -06:00
Michael Lamparski 8010604b2d move See also links to top 2018-05-09 18:30:32 -04:00
bors f305b025cf Auto merge of #48999 - GuillaumeGomez:add-repeat-on-slice, r=Kimundi
Add repeat method on slice

Fixes #48784.
2018-04-24 03:31:11 +00:00
Simon Sapin 90f29fbdb1 Replace SliceExt with inherent [T] methods in libcore 2018-04-21 09:45:18 +02:00
Simon Sapin de8ed6a1d6 Move non-allocating [u8] inherent methods to libcore
Fixes #45803
2018-04-21 09:45:18 +02:00
tinaun 78a8c25703 stabilize swap_with_slice feature 2018-04-17 00:49:24 -04:00
tinaun edc412c5a9 stabilize slice_rsplit feature 2018-04-17 00:48:23 -04:00
varkor 1aa61526a7 Add trivial early return for sort_by_cached_key 2018-04-09 16:44:20 +01:00
Guillaume Gomez 1ef70a00ab Add repeat method on slice 2018-03-28 09:02:26 +02:00
varkor 9c7b69e179 Remove mentions of unstable sort_by_cached key from stable documentation 2018-03-26 22:24:03 +01:00
varkor 81edd1796b Check that the size optimisation is not redundant 2018-03-18 12:50:58 +00:00
varkor 9896b38f01 Clarify time complexity 2018-03-18 12:50:56 +00:00
varkor ca3bed0c66 Improve and fix documentation for sort_by_cached_key 2018-03-17 20:18:08 +00:00
varkor b430cba343 Fix use of unstable feature in test 2018-03-17 17:25:23 +00:00
varkor f41a26f204 Add sort_by_cached_key method 2018-03-16 14:39:53 +00:00
varkor bdcc6f939a Index enumeration by minimally sized type 2018-03-16 13:57:08 +00:00
varkor 7dcfc07d2c Cull the quadratic 2018-03-16 13:57:08 +00:00
varkor 21fde0903b Update documentation 2018-03-16 13:57:07 +00:00
varkor b8452cc326 Clarify behaviour of sort_unstable_by_key with respect to sort_by_key 2018-03-16 13:57:07 +00:00
varkor 670e69e207 Update documentation for sort_by_key 2018-03-16 13:57:07 +00:00
varkor ea6a1bdf6b Compute each key only one during slice::sort_by_key 2018-03-16 13:57:07 +00:00
Corey Farwell b1a6c8bdd3 Stabilize [T]::rotate_{left,right}
https://github.com/rust-lang/rust/issues/41891
2018-02-22 20:12:38 -05:00