struct Rectangle {
width: u32,
length: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
self.width*self.length
}
}
fn main() {
let rect = &Rectangle {
width: 30,
length: 50,
};
println!("The Area is {}", rect.area())
}
Rust 结构体方法
猜你喜欢
转载自blog.csdn.net/qq2942713658/article/details/114734945
今日推荐
周排行