We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e9b69b commit 21cf9eaCopy full SHA for 21cf9ea
tests/ui/traits/new-solver/structural-resolve-field.rs
@@ -1,13 +1,35 @@
1
// compile-flags: -Ztrait-solver=next
2
// check-pass
3
4
-#[derive(Default)]
5
struct Foo {
6
x: i32,
7
}
8
+impl MyDefault for Foo {
9
+ fn my_default() -> Self {
10
+ Self {
11
+ x: 0,
12
+ }
13
14
+}
15
+
16
+trait MyDefault {
17
+ fn my_default() -> Self;
18
19
20
+impl MyDefault for [Foo; 0] {
21
22
+ []
23
24
25
+impl MyDefault for [Foo; 1] {
26
27
+ [Foo::my_default(); 1]
28
29
30
31
fn main() {
- let mut xs = <[Foo; 1]>::default();
32
+ let mut xs = <[Foo; 1]>::my_default();
33
xs[0].x = 1;
34
(&mut xs[0]).x = 2;
35
0 commit comments