This commit is contained in:
e2hang
2025-10-03 00:05:03 +08:00
parent 9d2885625d
commit 1f9543c16c
6 changed files with 58 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,31 @@
struct Student{
name: String,
age: i64,
birth: String,
score: f64
}
trait make_student{
fn get_name(&self) -> &str;
fn print(&self){
println!("{0} is my name, Oh yeah", &self.get_name());
}
}
impl make_student for Student{
fn get_name(&self) -> &str {
return &self.name;
}
}
fn main(){
let s = Student{
name: String::from("Van"),
age: 19,
birth: String::from("2025-09-30"),
score: 99.99
};
s.print();
}