I want to implement a trait for both a for reference and non-reference type. Do I have to implement the functions twice, or this is not idiomatic to do so?
Here\'s t
This is a good example for the Borrow trait.
use std::borrow::Borrow; struct Bar; trait Foo { fn hi(&self); } impl> Foo for B { fn hi(&self) { print!("hi") } } fn main() { let bar = Bar; (&bar).hi(); &bar.hi(); }