File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // traits5.rs
2
+ //
3
+ // Your task is to replace the '??' sections so the code compiles.
4
+ // Don't change any line other than 27.
5
+
6
+ // I AM NOT DONE
7
+
8
+ pub trait SomeTrait {
9
+ fn some_function ( & self ) -> bool {
10
+ true
11
+ }
12
+ }
13
+
14
+ pub trait OtherTrait {
15
+ fn other_function ( & self ) -> bool {
16
+ true
17
+ }
18
+ }
19
+
20
+ struct SomeStruct {
21
+ name : String ,
22
+ }
23
+
24
+ impl SomeTrait for SomeStruct { }
25
+ impl OtherTrait for SomeStruct { }
26
+
27
+ fn some_func ( item : ??) -> bool {
28
+ item. some_function ( ) && item. other_function ( )
29
+ }
30
+
31
+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -727,6 +727,17 @@ Instead of using concrete types as parameters you can use traits. Try replacing
727
727
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
728
728
"""
729
729
730
+ [[exercises ]]
731
+ name = " traits5"
732
+ path = " exercises/traits/traits5.rs"
733
+ mode = " compile"
734
+ hint = """
735
+ To ensure a paramter implements multiple traits use the '+ syntax'. Try replacing the
736
+ '??' with 'impl <> + <>'.
737
+
738
+ See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#specifying-multiple-trait-bounds-with-the--syntax
739
+ """
740
+
730
741
# QUIZ 3
731
742
732
743
[[exercises ]]
You can’t perform that action at this time.
0 commit comments