| Age | Commit message (Collapse) | Author | Lines |
|
Rename TryFrom's associated type and implement str::parse using TryFrom.
Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err".
See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968.
`TryFrom<&str>` and `FromStr` are equivalent, so have the latter provide the former to ensure that. Using `TryFrom` in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to
suggest implementing `TryFrom<&str>` instead for new code.
See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994
and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827.
Refs #33417.
|
|
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]
|
|
|
|
Drop of arrays is now translated in trans::block in an ugly way that I
should clean up in a later PR, and does not handle panics in the middle
of an array drop, but this commit & PR are growing too big.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Link core::slice to std::slice
|
|
Inline functions Ordering::{then, then_with}
@jongiddy noticed bad performance due to the lack of inlining on `then`
and `then_with`. I confirmed that inlining really is the culprit by
creating a custom `then` function and repeating his benchmark on my
machine with and without the `#[inline]` attribute.
The numbers were exactly the same on my machine without the attribute.
With `#[inline]` I got the same performance as I did with manually
inlined implementation.
The problem was reported in #37053.
|
|
A few improvements to the `core::hash` top-level docs.
Primarily opened to address the concerns brought up in
https://github.com/rust-lang/rust/issues/40498.
* run rustfmt on code blocks
* use `DefaultHasher` instead of deprecated `SipHasher`
* rename `hash` to `calculate_hash` to prevent confusion with the `hash`
method
|
|
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
|
|
Reword the non-dropping of `src` for `ptr::write{,_unaligned}`
@niconii Is it OK if I put your wording into the documentation?
CC @nagisa
|
|
Per discussion on the tracking issue, naming `TryFrom`'s associated type
`Error` is generally more consistent with similar traits in the Rust
ecosystem, and what people seem to assume it should be called. It
also helps disambiguate from `Result::Err`, the most common "Err".
See
https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968.
TryFrom<&str> and FromStr are equivalent, so have the latter provide the
former to ensure that. Using TryFrom in the implementation of
`str::parse` means types that implement either trait can use it.
When we're ready to stabilize `TryFrom`, we should update `FromStr` to
suggest implementing `TryFrom<&str>` instead for new code.
See
https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994
and
https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827.
Refs #33417.
|
|
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]`.
:06 :<06 :>06 :^06
before |-001.2| |-1.200| |-001.2| |-01.20|
after |-001.2| |-001.2| |-001.2| |-001.2|
|
|
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]
|
|
|
|
Also update some 128 bit builtins to be panic-free without relying
on the const evaluator.
|
|
|
|
@jongiddy noticed bad performance due to the lack of inlining on `then`
and `then_with`. I confirmed that inlining really is the culprit by
creating a custom `then` function and repeating his benchmark on my
machine with and without the `#[inline]` attribute.
The numbers were exactly the same on my machine without the attribute.
With `#[inline]` I got the same performance as I did with manually
inlined implementation.
|
|
|
|
Their relationship is:
* `resume_from = error_len.map(|l| l + valid_up_to)`
* error_len is always one of None, Some(1), Some(2), or Some(3).
When I started using resume_from I almost always ended up subtracting
valid_up_to to obtain error_len.
Therefore the latter is what should be provided in the first place.
|
|
Without this, code outside of the standard library needs to reimplement
most of the logic `from_utf8` to interpret the bytes after `valid_up_to()`.
|
|
Primarily opened to address the concerns brought up in
https://github.com/rust-lang/rust/issues/40498.
* run rustfmt on code blocks
* use `DefaultHasher` instead of deprecated `SipHasher`
* rename `hash` to `calculate_hash` to prevent confusion with the `hash`
method
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Add missing example for Display::fmt
r? @frewsxcv
|
|
|
|
|
|
Clarify handling of `src` in `ptr::write`
Fixes #39733.
|
|
Fixes #39733.
|
|
|
|
… 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.
|
|
Add missing docs and examples for fmt::Write
r? @frewsxcv
|
|
|
|
Additional docs for Vec, String, and slice trait impls
r? @steveklabnik
|
|
This affects the book, some missed things in the reference, the grammar,
and the standard library. Whew!
|
|
This reverts commit 7f1d1c6d9a7be5e427bace30e740b16b25f25c92.
The original commit was created because mdBook and rustdoc had
different generation algorithms for header links; now with
https://github.com/rust-lang/rust/pull/39966 , the algorithms
are the same. So let's undo this change.
... when I came across this problem, I said "eh, this isn't fun,
but it doesn't take that long." I probably should have just actually
taken the time to fix upstream, given that they were amenable. Oh
well!
|
|
Explain that a None is returned if the iterator is empty.
|
|
|
|
|
|
Allow more Cell methods for non-Copy types
Clearly, `get_mut` is safe for any `T`. The other two only provide unsafe pointers anyway.
The only remaining inherent method with `Copy` bound is `get`, which sounds about right to me.
I found the order if `impl` blocks in the file a little weird (first inherent impl, then some trait impls, then another inherent impl), but didn't change it to keep the diff small.
Contributes to #39264
|
|
Port books to mdbook
Part of https://github.com/rust-lang/rust/issues/39588
blocked on https://github.com/rust-lang/rust/pull/39431
As a first step towards the bookshelf, we ~vendor mdbook in-tree and~ port our books to it. Eventually, both of these books will be moved out-of-tree, but the nightly book will rely on doing the same thing. As such, this intermediate step is useful.
r? @alexcrichton @brson
/cc @azerupi
|