From f26485de1ad88be2cc9ff131a4aee57cea562a95 Mon Sep 17 00:00:00 2001 From: Matthew Woodcraft Date: Sat, 27 Nov 2021 11:53:22 +0000 Subject: [PATCH] Update 'Subtyping and Variance' example to use `dyn Trait` syntax This will allow the example to be built under edition 2021. --- src/subtyping.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subtyping.md b/src/subtyping.md index 3f5e35b46..15b0b206a 100644 --- a/src/subtyping.md +++ b/src/subtyping.md @@ -29,8 +29,8 @@ let subtype: &(for<'a> fn(&'a i32) -> &'a i32) = &((|x| x) as fn(&_) -> &_); let supertype: &(fn(&'static i32) -> &'static i32) = subtype; // This works similarly for trait objects -let subtype: &(for<'a> Fn(&'a i32) -> &'a i32) = &|x| x; -let supertype: &(Fn(&'static i32) -> &'static i32) = subtype; +let subtype: &(dyn for<'a> Fn(&'a i32) -> &'a i32) = &|x| x; +let supertype: &(dyn Fn(&'static i32) -> &'static i32) = subtype; // We can also substitute one higher-ranked lifetime for another let subtype: &(for<'a, 'b> fn(&'a i32, &'b i32))= &((|x, y| {}) as fn(&_, &_));