Merge pull request #1461 from clubby789/imported-main

Document importing `main`
This commit is contained in:
Eric Huss 2024-03-20 15:54:19 +00:00 committed by GitHub
commit 824b9156b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,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:
>
> * `()`