forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#73115 - RalfJung:rollup-jecowhz, r=RalfJung
Rollup of 10 pull requests Successful merges: - rust-lang#72026 (Update annotate-snippets-rs to 0.8.0) - rust-lang#72583 (impl AsRef<[T]> for vec::IntoIter<T>) - rust-lang#72615 (Fix documentation example for gcov profiling) - rust-lang#72761 (Added the documentation for the 'use' keyword) - rust-lang#72799 (Add `-Z span-debug` to allow for easier debugging of proc macros) - rust-lang#72811 (Liballoc impl) - rust-lang#72963 (Cstring `from_raw` and `into_raw` safety precisions) - rust-lang#73001 (Free `default()` forwarding to `Default::default()`) - rust-lang#73075 (Add comments to `Resolve::get_module`) - rust-lang#73092 (Clean up E0646) Failed merges: r? @ghost
- Loading branch information
Showing
24 changed files
with
655 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/doc/unstable-book/src/library-features/default-free-fn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# `default_free_fn` | ||
|
||
The tracking issue for this feature is: [#73014] | ||
|
||
[#73014]: https://github.com/rust-lang/rust/issues/73014 | ||
|
||
------------------------ | ||
|
||
Adds a free `default()` function to the `std::default` module. This function | ||
just forwards to [`Default::default()`], but may remove repetition of the word | ||
"default" from the call site. | ||
|
||
Here is an example: | ||
|
||
```rust | ||
#![feature(default_free_fn)] | ||
use std::default::default; | ||
|
||
#[derive(Default)] | ||
struct AppConfig { | ||
foo: FooConfig, | ||
bar: BarConfig, | ||
} | ||
|
||
#[derive(Default)] | ||
struct FooConfig { | ||
foo: i32, | ||
} | ||
|
||
#[derive(Default)] | ||
struct BarConfig { | ||
bar: f32, | ||
baz: u8, | ||
} | ||
|
||
fn main() { | ||
let options = AppConfig { | ||
foo: default(), | ||
bar: BarConfig { | ||
bar: 10.1, | ||
..default() | ||
}, | ||
}; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
It is not possible to define `main` with a where clause. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0646 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.