| Age | Commit message (Collapse) | Author | Lines |
|
This reverts commit ac73335f2f5421c914fa3900567696cc6dc73d8d.
|
|
|
|
|
|
Implement std::str::replacen
Replaces first N matches of a pattern with another string.
```
assert_eq!("acaaa".replacen(a, "b", 3), "bcbba")
```
|
|
Documentation of what Default does for each type
Addresses #36265
I haven't changed the following types due to doubts:
1)src/libstd/ffi/c_str.rs
2)src/libcore/iter/sources.rs
3)src/libcore/hash/mod.rs
4)src/libcore/hash/mod.rs
5)src/librustc/middle/privacy.rs
r? @steveklabnik
|
|
|
|
|
|
|
|
|
|
extend_with_element
Due to missing noalias annotations for &mut T in general (issue #31681),
in larger programs extend_from_slice and extend_with_element may both
compile very poorly. What is observed is that the .set_len() calls are
not lifted out of the loop, even for `Vec<u8>`.
Use a local length variable for the Vec length instead, and use a scope
guard to write this value back to self.len when the scope ends or on
panic. Then the alias analysis is easy.
This affects extend_from_slice, extend_with_element, the vec![x; n]
macro, Write impls for Vec<u8>, BufWriter, etc (but may / may not
have triggered since inlining can be enough for the compiler to get it right).
|
|
Add missing urls
r? @steveklabnik
|
|
|
|
Optimize BinaryHeap bounds checking
I was experimenting with d-ary binary heaps during the weekend (dead end) and I found that we could get some good improvements by removing bounds checking. Specially due to the panic-safe additional code, llvm can't really optimize them out.
```
name d_ary_heap:: ns/iter std___heap:: ns/iter diff ns/iter diff %
bench_build_insert 148,610 236,960 88,350 59.45%
bench_from_vec 243,846 299,719 55,873 22.91%
bench_insert_2000_empty 4,512 7,517 3,005 66.60%
bench_insert_2000_prefilled 28,665 32,605 3,940 13.74%
bench_pop_2000 111,515 128,005 16,490 14.79%
bench_pop_all 2,759,945 3,317,626 557,681 20.21%
peek_mut 23,186 23,635 449 1.94%
pop_modify_push 41,573 43,822 2,249 5.41%
test d_ary_heap::bench_build_insert ... bench: 148,610 ns/iter (+/- 10,687)
test d_ary_heap::bench_from_vec ... bench: 243,846 ns/iter (+/- 16,500)
test d_ary_heap::bench_insert_2000_empty ... bench: 4,512 ns/iter (+/- 136)
test d_ary_heap::bench_insert_2000_prefilled ... bench: 28,665 ns/iter (+/- 1,347)
test d_ary_heap::bench_pop_2000 ... bench: 111,515 ns/iter (+/- 104,677)
test d_ary_heap::bench_pop_all ... bench: 2,759,945 ns/iter (+/- 173,838)
test d_ary_heap::peek_mut ... bench: 23,186 ns/iter (+/- 106,254)
test d_ary_heap::pop_modify_push ... bench: 41,573 ns/iter (+/- 3,313)
test std___heap::bench_build_insert ... bench: 236,960 ns/iter (+/- 16,955)
test std___heap::bench_from_vec ... bench: 299,719 ns/iter (+/- 6,354)
test std___heap::bench_insert_2000_empty ... bench: 7,517 ns/iter (+/- 372)
test std___heap::bench_insert_2000_prefilled ... bench: 32,605 ns/iter (+/- 2,433)
test std___heap::bench_pop_2000 ... bench: 128,005 ns/iter (+/- 11,787)
test std___heap::bench_pop_all ... bench: 3,317,626 ns/iter (+/- 238,968)
test std___heap::peek_mut ... bench: 23,635 ns/iter (+/- 1,420)
test std___heap::pop_modify_push ... bench: 43,822 ns/iter (+/- 3,788)
```
Test code: https://github.com/arthurprs/heap-experiments
|
|
Clarify/fix formatting docs concerning fmt::Result/fmt::Error
1. `fmt::Result` != `io::Result<()>`
2. Formatters should only propagate errors, not return their own.
Confusion on reddit: https://www.reddit.com/r/rust/comments/4yorxr/is_implt_tostring_for_t_where_t_display_sized_a/
|
|
|
|
Use `#[prelude_import]` in `libcore` and `libstd`
r? @eddyb
|
|
|
|
|
|
They're the same thing but it's better to keep the terminology consistent.
|
|
Implement 1581 (FusedIterator)
* [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642.
* [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be?
* [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice.
* I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`.
* `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`.
Closes: #35602 (Tracking Issue)
Implements: rust-lang/rfcs#1581
|
|
It used to say "Furtheremore" instead of "Furthermore".
|
|
Doing otherwise would break traits like `ToString`.
|
|
|
|
rustdoc: remove the `!` from macro URLs and titles
Because the `!` is part of a macro use, not the macro's name. E.g., you write `macro_rules! foo` not `macro_rules! foo!`, also `#[macro_import(foo)]`.
(Pulled out of #35020).
|
|
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
|
|
This trait can be used to avoid the overhead of a fuse wrapper when an iterator
is already well-behaved.
Conforming to: RFC 1581
Closes: #35602
|
|
|
|
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
|
|
Make `vec::IntoIter` covariant again
Closes #35721
r? @alexcrichton
|
|
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
|
|
Closes #35721
|
|
Made vec_deque::Drain, hash_map::Drain, and hash_set::Drain covariant
Fixed the rest of the Drain iterators.
|
|
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
|
|
string: remove needless binding
|
|
doc: a value of type `&str` is called a "string slice"
|
|
Introduce `as_slice`/`as_mut_slice` methods on `std::vec::IntoIter` struct.
Similar to the `as_slice` method on `core::slice::Iter` struct.
|
|
|
|
Similar to the `as_slice` method on `core::slice::Iter` struct.
|
|
|
|
|
|
|
|
extend lifetime on binary_search_by_key of SliceExt trait
Fixes #34683.
|
|
|
|
This seems like an oversight, since the corresponding implementation for `Cow<[T]> where T: Clone` exists.
|
|
Add doc example for Vec
Fixes #29380.
r? @steveklabnik
|
|
|
|
|
|
|
|
implement `From<Vec<char>>` and `From<&'a [char]>` for `String`
Though there are ways to convert a slice or vec of chars into a string,
it would be nice to be able to just do `String::from(&['a', 'b', 'c'])`,
so this PR implements `From<Vec<char>>` and `From<&'a [char]>` for
String.
|
|
Rewrite `slice::chunks` doc example to not require printing.
None
|