feat: add tests

This commit is contained in:
2024-01-07 18:26:09 +08:00
parent 526dd4172b
commit 7ec4c4a526
15 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
use std::ops::Deref;
trait WithName {
fn get_name(&self) -> &str;
}
struct Human {
name: String,
}
impl Human {
fn new(name: String) -> Self {
Self { name }
}
}
impl WithName for Human {
fn get_name(&self) -> &str {
self.name.deref()
}
}
fn main() {
let with_name = Human::new("Hatter".into());
println!("With name: {}", with_name.get_name());
}