We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9bd5c7c commit 98a97d7Copy full SHA for 98a97d7
exercises/traits/traits3.rs
@@ -1,17 +1,8 @@
1
-// traits3.rs
2
-//
3
-// Your task is to implement the Licensed trait for both structures and have
4
-// them return the same information without writing the same function twice.
5
6
-// Consider what you can add to the Licensed trait.
7
8
-// Execute `rustlings hint traits3` or use the `hint` watch subcommand for a
9
-// hint.
10
-
11
-// I AM NOT DONE
12
13
pub trait Licensed {
14
- fn licensing_info(&self) -> String;
+ // 核心修改:为trait方法添加默认实现,实现代码复用
+ fn licensing_info(&self) -> String {
+ String::from("Some information")
+ }
15
}
16
17
struct SomeSoftware {
0 commit comments