| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Fix subject-verb agreement in copypasta: "`AsRef` dereference" to
"`AsRef` dereferences".
Formalize "eg" to "e.g." Italicization of common Latin abbreviations
seems to be going out of style in written English, so I left it plain.
|
|
Remove redundant `&mut ref mut` in doc for Result::as_mut()
While a good example of how `&mut ref mut` is a no-op, I don't think we should show that here :)
See https://users.rust-lang.org/t/mnemonic-for-reading-qualifiers/6853
r? @steveklabnik
|
|
Provide a cleaner documentation for 'write!'
Hello!
This is my attempt to fix #35110
Any feedback is more than welcome!
Cheers!
|
|
|
|
|
|
Implement `RefCell::{try_borrow, try_borrow_mut}`
CC #35070
r? @alexcrichton
|
|
extend lifetime on binary_search_by_key of SliceExt trait
Fixes #34683.
|
|
|
|
|
|
The pow() method for unsigned integers produced 0 instead of trapping
overflow for certain inputs. Calls such as 2u32.pow(1024) produced 0
when they should trap an overflow. This also adds tests for the
correctly handling overflow in unsigned pow().
For issue number #34913
|
|
|
|
Clean up `std::raw` docs
There is no longer a `Repr` trait, so mentioning a missing impl of it was potentially confusing.
r? @steveklabnik
|
|
There is no longer a `Repr` trait, so mentioning a missing impl of it
was potentially confusing.
|
|
|
|
Add Derive not possible question to Copy
This adds a question and answer to the Q&A section of the Copy
docs. Specifically, it asks the question I asked while reading
the docs, and gives its answer.
cc @steveklabnik
|
|
Clarify UnsafeCell docs; fix #34496
None
|
|
|
|
|
|
|
|
This crate was failing to compile due to dead_code/unused_imports
warnings. This commits disables these two lints for these targets.
|
|
This adds a question and answer to the Q&A section of the Copy
docs. Specifically, it asks the question I asked while reading
the docs, and gives its answer.
|
|
Add non-panicking abs() functions to all signed integer types.
Currently, calling abs() on one of the signed integer types might panic (in
debug mode at least) because the absolute value of the largest negative value
can not be represented in that signed type. Unlike all other integer
operations, there is currently not a non-panicking version on this function.
This seems to just be an oversight in the design, therefore just adding it now.
|
|
Update docs for assert! and debug_assert!
Refer to #34455
|
|
Add documentation example for `str::Chars::as_str`.
None
|
|
Escape fewer Unicode codepoints in `Debug` impl of `str`
Use the same procedure as Python to determine whether a character is
printable, described in [PEP 3138]. In particular, this means that the
following character classes are escaped:
- Cc (Other, Control)
- Cf (Other, Format)
- Cs (Other, Surrogate), even though they can't appear in Rust strings
- Co (Other, Private Use)
- Cn (Other, Not Assigned)
- Zl (Separator, Line)
- Zp (Separator, Paragraph)
- Zs (Separator, Space), except for the ASCII space `' '` `0x20`
This allows for user-friendly inspection of strings that are not
English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`).
Fixes #34318.
CC #34422.
[PEP 3138]: https://www.python.org/dev/peps/pep-3138/
|
|
Currently, calling abs() on one of the signed integer types might panic (in
debug mode at least) because the absolute value of the largest negative value
can not be represented in that signed type. Unlike all other integer
operations, there is currently not a non-panicking version on this function.
This seems to just be an oversight in the design, therefore just adding it now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
document DoubleEndedIterator::next_back
document DoubleEndedIterator::next_back
fixes #34726
|
|
Add more docs - mostly warnings - to std::mem::transmute
|
|
|
|
|
|
Add BuildHasher example
r? @steveklabnik
|
|
|
|
Use the same procedure as Python to determine whether a character is
printable, described in [PEP 3138]. In particular, this means that the
following character classes are escaped:
- Cc (Other, Control)
- Cf (Other, Format)
- Cs (Other, Surrogate), even though they can't appear in Rust strings
- Co (Other, Private Use)
- Cn (Other, Not Assigned)
- Zl (Separator, Line)
- Zp (Separator, Paragraph)
- Zs (Separator, Space), except for the ASCII space `' '` (`0x20`)
This allows for user-friendly inspection of strings that are not
English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`).
Fixes #34318.
[PEP 3138]: https://www.python.org/dev/peps/pep-3138/
|
|
|
|
3Hren:issue/xx/reinterpret-format-precision-for-strings, r=alexcrichton
feat: reinterpret `precision` field for strings
This commit changes the behavior of formatting string arguments with both width and precision fields set.
Documentation says that the `width` field is the "minimum width" that the format should take up. If the value's string does not fill up this many characters, then the padding specified by fill/alignment will be used to take up the required space.
This is true for all formatted types except string, which is truncated down to `precision` number of chars and then all of `fill`, `align` and `width` fields are completely ignored.
For example: `format!("{:/^10.8}", "1234567890);` emits "12345678". In the contrast Python version works as the expected:
```python
>>> '{:/^10.8}'.format('1234567890')
'/12345678/'
```
This commit gives back the `Python` behavior by changing the `precision` field meaning to the truncation and nothing more. The result string *will* be prepended/appended up to the `width` field with the proper `fill` char.
__However, this is the breaking change, I admit.__ Feel free to close it, but otherwise it should be mentioned in the `std::fmt` documentation somewhere near of `fill/align/width` fields description.
|
|
|
|
core: impl From<T> for Option<T>
First, the semantics of this `impl` seem spot on. If I have a value `T`, and I wish to make a `Option<T>`, then `Option::from(val)` should always give `Some(val)`.
Second, this allows improvement for several APIs that currently take `Option<T>` as arguments. Consider:
```rust
fn set_read_timeout(&mut self, timeout: Option<u32>) {
// ...
}
x.set_read_timeout(Some(30));
x.set_read_timeout(Some(10));
x.set_read_timeout(None);
```
With this `impl`:
```rust
fn set_read_timeout<T: Into<Option<u32>>>(&mut self, timeout: T) {
let timeout = timeout.into();
// ...
}
x.set_read_timeout(30);
x.set_read_timeout(10);
x.set_read_timeout(Some(10)); // backwards compatible
x.set_read_timeout(None);
```
The change to those methods aren't included, but could be modified later.
r? @sfackler
|
|
|
|
Rollup of 5 pull requests
- Successful merges: #34807, #34853, #34875, #34884, #34889
- Failed merges:
|
|
Implement traits for variadic function pointers
Closes https://github.com/rust-lang/rust/issues/34874
cc https://github.com/rust-lang/rust/pull/28268
r? @alexcrichton
|
|
Add `is_empty` function to `ExactSizeIterator`
All other types implementing a `len` functions have `is_empty` already.
|
|
|
|
Indicate where `std::slice` structs originate from.
None
|