| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
|
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
|
|
|
|
|
|
|
|
|
Before this change `SliceConcatExt` was an unstable extension trait
with stable methods. It was in the libstd prelude, so that its methods
could be used on the stable channel.
This replaces it with inherent methods,
which can be used without any addition to the prelude.
Since the methods are stable and very generic
(with for example a return type that depends on the types of parameters),
an helper trait is still needed.
But now that trait does not need to be in scope for the methods to be used.
Removing this depedency on the libstd prelude allows the methods to be used
in `#![no_std]` crate that use liballoc, which does not have its own
implicitly-imported prelude.
|
|
r=sfackler
SliceConcatExt::connect defaults to calling join
It makes sense to default a deprecated method to the new one. Precedence example is `Error::cause` defaults to calling `Error::source`.
|
|
|
|
|
|
|
|
|
|
documentation"
This reverts commit 9c7b69e17909ceb090a1c4b8882a4e0924a2a755.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
}
```
|
|
|
|
|
|
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
|
|
Fixes #55177
|
|
Fixes #47115
|
|
These work exactly like the normal chunks iterators but start creating
chunks from the end of the slice.
See #55177 for the tracking issue
|
|
|
|
|
|
|
|
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.
|
|
|
|
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815
and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
|
|
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.
|
|
|
|
Stabilize SliceIndex trait.
CC #35729
According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
|
|
further reduce unsafe fn calls
reduce right drift
assert! sufficient capacity
|
|
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
|
|
Fixes #35729
According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
|
|
|
|
|
|
|
|
Add repeat method on slice
Fixes #48784.
|
|
|
|
Fixes #45803
|
|
|