How to see a function signature in terminal?

like I want to know std::thread, and know

    pub fn spawn<F, T>(f: F) -> JoinHandle<T>
            F: FnOnce() -> T + Send + 'static,
            T: Send + 'static

I want to print it to terminal for quick check?
I already know rustup doc can open some help, but not function signature.

I'm sorry, you want to know the function signature of spawn?
Here's its doc page:

And if you wanted to get an fn object type try the following:

let _: () = std::thread::spawn;

Unfortunately this reports it as being a fn(_) -> JoinHandle<_> so it's not all that useful, so you will need to use the docs for some extra information. Also, because this is a generic function, and there is no such thing as a generic function pointer in rust, you will have to monomorphize the function into a fn type that satisfies spawn's type constraints.

1 Like

You can open up the docs offline using rustup doc

Thank you, can I get this information from terminal, like
help std::thread::spawn , cargo cli provide this function?

yes, i read again and found std API in rustup doc

No, you can't. But since you have the official docs offline, you can look at those instead


A lot of the language-server plugins (for vim and the like) have a command to query function signatures or even full docs.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.