add zh/method

This commit is contained in:
sunface
2022-03-03 16:33:10 +08:00
parent bd928764ab
commit 7ea642691e
4 changed files with 262 additions and 5 deletions

View File

@ -193,7 +193,7 @@ struct TrafficLight {
impl TrafficLight {
// 1. implement a assotiated function `new`,
// 2. it will return a TrafficLight contains color "red"
// 3. must use `Self`, DONT use `TrafficLight`
// 3. must use `Self`, DONT use `TrafficLight` in fn signatures or body
pub fn new()
pub fn get_state(&self) -> &str {
@ -216,7 +216,7 @@ struct Rectangle {
height: u32,
}
// rewrite Rectangle to use multiple `impl` blocks
// using multiple `impl` blocks to rewrite the code below
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height