From 5f49f2d882ccb2c6fd459104c842876c329122ce Mon Sep 17 00:00:00 2001 From: Eric Egli <43848365+eegli@users.noreply.github.com> Date: Wed, 17 May 2023 08:25:40 +0200 Subject: [PATCH 1/2] fix example code in impl docs --- src/types/impl-trait.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/impl-trait.md b/src/types/impl-trait.md index 413f999f8..94e675e72 100644 --- a/src/types/impl-trait.md +++ b/src/types/impl-trait.md @@ -98,6 +98,7 @@ The function: ```rust,ignore fn foo() -> T { +} ``` allows the caller to determine the return type, `T`, and the function returns that type. @@ -106,6 +107,7 @@ The function: ```rust,ignore fn foo() -> impl Trait { +} ``` doesn't allow the caller to determine the return type. From 3f5f3b2428275fa0202ec8f289f7e03d3ebaf832 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 22 May 2023 10:39:42 -0700 Subject: [PATCH 2/2] Remove use of `ignore` from examples. --- src/types/impl-trait.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/types/impl-trait.md b/src/types/impl-trait.md index 94e675e72..af900408e 100644 --- a/src/types/impl-trait.md +++ b/src/types/impl-trait.md @@ -31,15 +31,15 @@ The caller must provide a type that satisfies the bounds declared by the anonymo For example, these two forms are almost equivalent: -```rust,ignore +```rust trait Trait {} // generic type parameter -fn foo(arg: T) { +fn with_generic_type(arg: T) { } // impl Trait in argument position -fn foo(arg: impl Trait) { +fn with_impl_trait(arg: impl Trait) { } ``` @@ -96,8 +96,11 @@ With `impl Trait`, unlike with a generic type parameter, the function chooses th The function: -```rust,ignore +```rust +# trait Trait {} fn foo() -> T { + // ... +# panic!() } ``` @@ -105,8 +108,11 @@ allows the caller to determine the return type, `T`, and the function returns th The function: -```rust,ignore +```rust +# trait Trait {} +# impl Trait for () {} fn foo() -> impl Trait { + // ... } ```