Cannot find method or associated constant `join` in `std::⁠thread::JoinHandle`

pub type RunnableJoinHandle = Box<dyn RunnableJoinHandleTrait>;
pub trait RunnableJoinHandleTrait {
    fn join(self) -> Result<(), ()>;
}
impl RunnableJoinHandleTrait for std::thread::JoinHandle<()> {
    fn join(self) -> Result<(), ()> {
        <Self as std::thread::JoinHandle<()>>::join(self)
    }
}

Error:

error[E0576]: cannot find method or associated constant `join` in `std::thread::JoinHandle`
 --> src/lib.rs:7:48
  |
7 |         <Self as std::thread::JoinHandle<()>>::join(self)
  |                                                ^^^^ not found in `std::thread::JoinHandle`

but clearly the method exists JoinHandle in std::thread - Rust

The syntax you're looking for is std::thread::JoinHandle::join(self), as is only used to access trait members and JoinHandle is a struct.

In case anyone else is about to make an issue for the bad error message, it already exists: Misleading error when using fully qualified trait syntax without trait · Issue #98565 · rust-lang/rust · GitHub.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.