Where can I learn about "imp"

"Read the source, Luke." Obi Wan Code Noby

When trying to figure things out, I often go to the source. Inside I find places like this
with code

pub struct Command {
    inner: imp::Command,

I assume the "imp::" part is some kind of compiler magic? When I google anything with "imp" all I get is results regarding "impl" . When I grep the rust source code I find "imp::" in many places, but can not find where "imp" is explained. Please point me to the source of information that can explain "imp"

use crate::sys::process as imp;

at the top-ish (line 118)


It's just a naming convention for a private module that handles the actual implementation. Often, this is done to help separate large chunks of platform-specific code.

1 Like

Oh .... I grepped better.

rg 'as imp' .

and I found what I was looking for in the process.rs file.

use crate::sys::process as imp;

Following up through all the cfg, here’s the implementation of process::Command for “unix”-like systems.


By the way, for exploring the standard library in more detail, it can be useful to check out the rust source and to set up your IDE so you can just jump to the definition.

Peek 2022-12-11 15-37


Or… an even more straightforward approach in this case: Use the website stdrs.dev which contains rust standard library docs compiled with private items visible, and with the unstable option enabled that adds links to the source code view.

Peek 2022-12-11 15-48


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.