0

在这种情况下,错误归因指的是什么?如何根据传入的参数将我的代码修复为 println?

运行下面的代码会引发错误:

error: expected type, found `10`
  --> src/main.rs:21:27
   |
21 |    tellTime(Clock:Sundial(10));
   |                           ^^ expecting a type here because of type ascription

main.rs:

enum Clock {
    Sundial(u8),
    Digital(u8, u8),
    Analog(u8, u8, u8),
}

fn tellTime(clock: Clock) {
    match clock {
      Clock::Sundial(hours) =>
          println!("Time is: {}", hours),
      Clock::Digital(hours, mins) =>
          println!("Time is: {}:{}", hours, mins),
      Clock::Analog(hours, mins, secs) =>
          println!("Time is: {}:{}:{}", hours, mins, secs),
      _ => println!("Not a clock!")

    }

}
fn main() {
   tellTime(Clock:Sundial(10));
}
4

0 回答 0