diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2020-01-15 11:14:05 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2020-01-16 09:49:14 -0800 |
| commit | d7a62124018ce8438caeedca203d39997f130b49 (patch) | |
| tree | 1bbf6438d05290a84c4b8114fb99175edbc6eaf4 /src/librustc_error_codes/error_codes | |
| parent | c305ac31c09fdd5078fa0e69e718b4da10d9e354 (diff) | |
| download | rust-d7a62124018ce8438caeedca203d39997f130b49.tar.gz rust-d7a62124018ce8438caeedca203d39997f130b49.zip | |
review comments
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0746.md | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_error_codes/error_codes/E0746.md b/src/librustc_error_codes/error_codes/E0746.md index 2df27bcf0bf..041061f3380 100644 --- a/src/librustc_error_codes/error_codes/E0746.md +++ b/src/librustc_error_codes/error_codes/E0746.md @@ -12,8 +12,8 @@ impl T for S { fn bar(&self) {} } -// Having the trait `T` as return type is invalid because bare traits do not -// have a statically known size: +// Having the trait `T` as return type is invalid because +// bare trait objects do not have a statically known size: fn foo() -> dyn T { S(42) } @@ -32,15 +32,15 @@ If there is a single type involved, you can use [`impl Trait`]: # fn bar(&self) {} # } // The compiler will select `S(usize)` as the materialized return type of this -// function, but callers will only be able to access associated items from `T`. +// function, but callers will only know that the return type implements `T`. fn foo() -> impl T { S(42) } ``` If there are multiple types involved, the only way you care to interact with -them is through the trait's interface and having to rely on dynamic dispatch is -acceptable, then you can use [trait objects] with `Box`, or other container +them is through the trait's interface, and having to rely on dynamic dispatch +is acceptable, then you can use [trait objects] with `Box`, or other container types like `Rc` or `Arc`: ``` |
