Skip to content

Commit 24d6292

Browse files
authored
Merge pull request #1110 from mattheww/2021-11_subtyping_example
Update 'Subtyping and Variance' example to use `dyn Trait` syntax
2 parents c0f222d + f26485d commit 24d6292

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/subtyping.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ let subtype: &(for<'a> fn(&'a i32) -> &'a i32) = &((|x| x) as fn(&_) -> &_);
2929
let supertype: &(fn(&'static i32) -> &'static i32) = subtype;
3030

3131
// This works similarly for trait objects
32-
let subtype: &(for<'a> Fn(&'a i32) -> &'a i32) = &|x| x;
33-
let supertype: &(Fn(&'static i32) -> &'static i32) = subtype;
32+
let subtype: &(dyn for<'a> Fn(&'a i32) -> &'a i32) = &|x| x;
33+
let supertype: &(dyn Fn(&'static i32) -> &'static i32) = subtype;
3434

3535
// We can also substitute one higher-ranked lifetime for another
3636
let subtype: &(for<'a, 'b> fn(&'a i32, &'b i32))= &((|x, y| {}) as fn(&_, &_));

0 commit comments

Comments
 (0)