| Age | Commit message (Collapse) | Author | Lines |
|
[T]::rsplit() and rsplit_mut(), #41020
|
|
Add ptr::offset_to
This PR adds a method to calculate the signed distance (in number of elements) between two pointers. The resulting value can then be passed to `offset` to get one pointer from the other. This is similar to pointer subtraction in C/C++.
There are 2 special cases:
- If the distance is not a multiple of the element size then the result is rounded towards zero. (in C/C++ this is UB)
- ZST return `None`, while normal types return `Some(isize)`. This forces the user to handle the ZST case in unsafe code. (C/C++ doesn't have ZSTs)
|
|
Allow using Vec::<T>::place_back for T: !Clone
The place_back was likely put into block with `T: Clone` bound by mistake.
|
|
Fix links
part of https://github.com/rust-lang/rust/issues/40912
[]\n() is not actually a link.
r? @frewsxcv @GuillaumeGomez
|
|
Fixed typo in doc comments for swap_remove
While reading the Vec docs, I came across the docs for swap_remove. I believe there is a typo in the comment and ```return``` should be ```returns```. This PR fixes this issue.
I also feel that the entire doc comment is a bit of a run-on and could be changed to something along the lines of ```Removes an element from anywhere in the vector and returns it. The vector is mutated and the removed element is replaced by the last element of the vector. ```
Thoughts?
|
|
Improve some docs for VecDeque
r? @GuillaumeGomez
|
|
part of https://github.com/rust-lang/rust/issues/40912
[]\n() is not actually a link.
|
|
|
|
|
|
This change moves:
1. `libcoretest` into `libcore/tests`
2. `libcollectionstest` into `libcollections/tests`
This is a follow-up to #39561.
|
|
steveklabnik
|
|
|
|
|
|
|
|
Modify str Structs descriptions
References #29375. Modified descriptions of multiple structs to be more in line with structs found under [`std::iter`](https://doc.rust-lang.org/std/iter/#structs), such as [`Chain`](https://doc.rust-lang.org/std/iter/struct.Chain.html) and [`Enumerate`](https://doc.rust-lang.org/std/iter/struct.Enumerate.html)
|
|
|
|
Checked slicing for strings
cc https://github.com/rust-lang/rust/issues/39932
|
|
|
|
|
|
The place_back was likely put into block with `T: Clone` bound by mistake.
|
|
Specialize Vec::from_iter for vec::IntoIter
It's fairly common to expose an API which takes an `IntoIterator` and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this `from_iter`
simply reassemble the original `Vec` with no actual iteration or
reallocation.
r? @aturon
|
|
Update docs for std::str
fixes #29375
I noticed there are docs for the `str` primitive type, which contained extensive examples, so my additions give a more general explanation of `&str`. But please let me know if something can be explained more or changed.
r? @steveklabnik
|
|
|
|
|
|
Unnecessary iteration in BTreeMap::drop
`IntoIter::drop` already iterates.
|
|
`IntoIter::drop` already iterates.
|
|
|
|
|
|
|
|
What is this magic‽
|
|
|
|
It's fairly common to expose an API which takes an `IntoIterator` and
immediately collects that into a vector. It's also common to buffer
a bunch of items into a vector and then pass that into one of these
APIs. If the iterator hasn't been advanced, we can make this `from_iter`
simply reassemble the original `Vec` with no actual iteration or
reallocation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Change how the `0` flag works in format!
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixes #39997 [breaking-change]
|
|
Add mention of None as possible return. Closes #40435.
This commit adds a small mention to some methods that None is returned when the slice is empty.
|
|
minor wording tweak to slice::{as_ptr, as_mut_ptr}
Per #37334, the slice-as-pointer methods mentioned that "modifying the slice may cause its buffer to be reallocated", when in fact modifying the *slice* itself would cause no such change. (It is a borrow, after all!) This is a tweak to the wording of that line to stress it's the *collection* that could cause the buffer to be reallocated.
r? @steveklabnik
|
|
|
|
|
|
|
|
|
|
|
|
Fix documentation for Vec::dedup_by.
The previous docstring was copied from dedup_by_key.
|
|
fix format grammar
This is just a trivial change to get the escaped squigglies into the grammar.
r? @steveklabnik
|
|
r=GuillaumeGomez
Remove function invokation parens from documentation links.
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
|