We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a1cff1c commit b867376Copy full SHA for b867376
src/doc/unstable-book/src/language-features/trait-upcasting.md
@@ -0,0 +1,26 @@
1
+# `trait_upcasting`
2
+
3
+The tracking issue for this feature is: [#31436]
4
5
+[#65991]: https://github.com/rust-lang/rust/issues/65991
6
7
+------------------------
8
9
+The `trait_upcasting` feature adds support for trait upcasting. This allows a
10
+trait object of type `dyn Foo` to be cast to a trait object of type `dyn Bar`
11
+so long as `Foo: Bar`.
12
13
+```rust,edition2018
14
+#![feature(trait_upcasting)]
15
16
+trait Foo {}
17
18
+trait Bar: Foo {}
19
20
+impl Foo for i32 {}
21
22
+impl<T: Foo + ?Sized> Bar for T {}
23
24
+let foo: &dyn Foo = &123;
25
+let bar: &dyn Bar = foo;
26
+```
0 commit comments