Vehicle Trait
Define a trait Vehicle with two methods: name(&self) -> &str and speed(&self) -> i32. Implement it for Car (name: "Car", speed: 120) and Bike (name: "Bike", speed: 25). Write a function race_info that takes &impl Vehicle and prints the vehicle info.
Expected output:
text
Car goes 120 km/h Bike goes 25 km/h
Hints:
- Use unit structs:
struct Car;andstruct Bike; fn race_info(v: &impl Vehicle)prints usingv.name()andv.speed()
rust
fn main() {
}