fn longest<'a>(a: &'a str, b: &'a str) -> &'a str {
if a.len() > b.len() {
a
} else {
b
}
}
struct ImportantExcerpt<'a> {
part: &'a str,
}
struct Car {
name: String,
speed: u32,
}
impl Car {
fn get_speed(&self) -> u32 {
self.speed
}
fn get_name(&self) -> String {
self.name.clone()
}
fn move_(&self, speed: u32) -> String {
format!("{} moves at {} km/h", self.name, speed)
}
}
#[test]
fn explore() {
let a = String::from("hello");
let b = String::from("world");
let c = longest(a.as_str(), b.as_str());
println!("{}", c);
assert_eq!(c, "world");
}
fn main() {
println!("{}", longest("hello", "world"));
let i = ImportantExcerpt { part: "hello" };
println!("{}", i.part);
}