| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8
With the list of files from the script in `outstanding_files`, the
relevant commands were:
$ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
$ rg libcore outstanding_files | xargs git checkout --
Repeating this process several months apart should get us coverage of
most of the rest of libcore.
|
|
|
|
|
|
|
|
|
|
This removes several warnings in IDE.
|
|
|
|
`std::panic` is already stable.
`core::panic::PanicInfo` and `core::panic::Location` are stable
and can be used through that path because of a bug
in stability checking: https://github.com/rust-lang/rust/issues/15702
|
|
#44489 was closed when the `#[panic_handler]` attribute was stabilized.
|
|
|
|
|
|
Note `#![unstable]` v.s. `#[unstable]`
|
|
|
|
|
|
|
|
|
|
Add some comments to panic runtime
|
|
|
|
|
|
|
|
|
|
Stabilize Result::map_or_else
Stabilized this API:
```rust
impl<T, E> Result<T, E> {
pub fn map_or_else<U, D: FnOnce(E) -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U {
match self {
Ok(t) => f(t),
Err(e) => default(e),
}
}
}
```
Closes #53268
r? @SimonSapin
|
|
make `./x.py bench` again
Fixes #54016
|
|
mem::forget docs: mention ManuallyDrop
Cc @SimonSapin @Centril
|
|
|
|
|
|
Clarify Step Documentation
While the redesign is in progress (#62886), clarify the purpose of replace_zero and replace_one.
First, "returning itself" is technically impossible due to the function signature of &mut self -> Self. A clone or copy operation must be used. So this is now explicitly stated in the documentation.
Second, the added docs give some guidance about the actual contract around implementation of replace_zero and replace one. Specifically, the only usage is to create a range with no more steps, by setting start to replace_one and end to replace_zero. So the only property that is actually used is `replace_one > replace_zero`. See https://github.com/rust-lang/rust/issues/42168#issuecomment-489554232
The new documentation does not say that is the *only* contract, and so it should not be considered an api change. It just highlights the most important detail for implementors.
The redesign doesn't seem to be landing any time soon, so this is a stopgap measure to reduce confusion in the meantime.
|
|
add fn type_name_of_val
This function is often useful during testing and mirrors `align_of_val` and `size_of_val`.
# Example
Showing the default type of integers.
```rust
let x = 7;
println!("per default, integers have the type: {}", std::any::type_name_of_val(&x));
```
To my knowledge this can currently not be done without defining a function similar to `type_name_of_val`.
|
|
follow the convention in this file to use third-person singular verbs
|
|
Document pitfall with `impl PartialEq<B> for A`
Fixes #66476 by turning the violating example into an explicit
counterexample.
|
|
|
|
Fixes #66476 by turning the violating example into an explicit
counterexample.
|
|
|
|
|
|
While the redesign is in progress (#62886), clarify the purpose of replace_zero and replace_one.
|
|
|
|
This skips the loop when the element type is known not to have drop glue, even in debug mode.
|
|
Suggest borrowing when it would satisfy an unmet trait bound
When there are multiple implementors for the same trait that is present
in an unmet binding, modify the E0277 error to refer to the parent
obligation and verify whether borrowing the argument being passed in
would satisfy the unmet bound. If it would, suggest it.
Fix #56368.
|
|
Clarify transmute_copy documentation example
Currently the documentation for `transmute_copy` implies that the function accepts a slice due to the variable name chosen in the example. This is misleading as `foo_slice` is actually an array and `transmute_copy` cannot take an unsized type anyway.
This PR just clarifies things by renaming the variable used in the example.
|
|
When there are multiple implementors for the same trait that is present
in an unmet binding, modify the E0277 error to refer to the parent
obligation and verify whether borrowing the argument being passed in
would satisfy the unmet bound. If it would, suggest it.
|
|
|
|
|
|
|
|
add Result::map_or
This PR adds this API to make it consistent with `Option::map_or`.
```rust
impl<T, E> Result<T, E> {
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
match self {
Ok(t) => f(t),
Err(_) => default,
}
}
}
```
This API is very small. We already has a similar API for `Option::map_or`.
|
|
add raw ptr variant of UnsafeCell::get
This has come up recently in https://github.com/rust-lang/rust/pull/66051 (Cc @Centril @pitdicker) as well as in discussion with @nikomatsakis and in unrelated discussion with @withoutboats.
|
|
Fix documentation for `Iterator::count()`.
The documentation of std::core::Iterator::count() stated that the number returned is the number of times `next` is called on the iterator. However this is not true as the number of times `next` is called is exactly one plus the number returned by `count()`.
|
|
|
|
|