From trait discoverability

Hi Friends,

I'm fairly new to Rust and am having the following issue. The codebase I work in liberally uses the From<Thing> for OtherThing trait. Invocations of this trait look like some_thing.into(). My problem is that its difficult to tell where this is called. For example, lets say I have the following definition:

struct Person {
  first_name: String,
  last_name: String
}

impl From<MyStruct> for String {
  fn from(m: MyStruct) -> String {
    format!("{},{}", m.first_name, m.last_name)
  }
}

pub fn do_thing(s: String) {
  println!("S is: {}", s);
}


pub fn main() {
  let p = Person{
    first_name: String::from("dave"), 
    last_name: String::from("someone")
  };
  do_thing(p.into());
}

Trying to find invocations of this trait via calls to into is difficult. I have to find all variables of type MyStruct, that are being implicitly cast to String. Is there a better way to do this? If not is there a better way to invoke this trait to make it easier to search?

Thank you!

If you comment out the From implementation then run cargo check --message-format short, the compiler will tell you all the locations it was used.

Edit: cheeky playground demo:

Hi Emy,

Thanks for the response! Commenting out the trait and finding what doesn't compile is brilliant! I was hoping that rust analyzer would provide a lookup without having to edit code, but I'll take it.