【发布时间】:2021-08-23 23:43:24
【问题描述】:
// `Inches`, a tuple struct that can be printed
#[derive(Debug)]
struct Inches(i32);
impl Inches {
fn to_centimeters(&self) -> Centimeters {
let &Inches(inches) = self;
Centimeters(inches as f64 * 2.54)
}
}
我理解函数签名是以Inches结构的引用作为参数,函数定义中的第一行是什么意思?
【问题讨论】:
标签: struct rust implementation