Document importing `main`

This commit is contained in:
clubby789 2024-01-30 18:13:16 +00:00
parent a0b119535e
commit 50a2c87f82
1 changed files with 11 additions and 0 deletions

View File

@ -119,6 +119,17 @@ fn main() -> impl std::process::Termination {
}
```
The `main` function may be an import, e.g. from an external crate or from the current one.
```rust
mod foo {
pub fn bar() {
println!("Hello, world!");
}
}
use foo::bar as main;
```
> **Note**: Types with implementations of [`Termination`] in the standard library include:
>
> * `()`