Skip to content

Commit 98a97d7

Browse files
authored
Update traits3.rs
1 parent 9bd5c7c commit 98a97d7

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

exercises/traits/traits3.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
131
pub trait Licensed {
14-
fn licensing_info(&self) -> String;
2+
// 核心修改:为trait方法添加默认实现,实现代码复用
3+
fn licensing_info(&self) -> String {
4+
String::from("Some information")
5+
}
156
}
167

178
struct SomeSoftware {

0 commit comments

Comments
 (0)