Skip to content

Commit f144b1c

Browse files
committed
w
1 parent 459bd52 commit f144b1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/trait-bounds.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ If there are multiple ways to satisfy a trait bound, some groups of candidate ar
7474
- impls
7575
- global where-bounds
7676

77+
```rust
78+
struct Container<T> {
79+
inner: Vec<T>,
80+
}
81+
impl<T: Clone> for Container<T> {
82+
fn clone(&self) -> Self {
83+
Container { inner: self.inner.clone() }
84+
}
85+
}
86+
87+
fn is_clone<T: Clone>() {}
88+
fn generic_fn<T: Clone>() {
89+
// `Container<T>: Clone` is satisfied via the impl above. This requires
90+
// the nested trait bound `T: Clone` which is satisfied via the where-bound.
91+
is_clone::<Container<T>>();
92+
}
93+
```
94+
7795
r[bound.trait-object]
7896
Trait and lifetime bounds are also used to name [trait objects].
7997

0 commit comments

Comments
 (0)