Skip to content

Commit 824b915

Browse files
authored
Merge pull request #1461 from clubby789/imported-main
Document importing `main`
2 parents b6779f4 + 50a2c87 commit 824b915

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/crates-and-source-files.md

+11
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ fn main() -> impl std::process::Termination {
8686
}
8787
```
8888

89+
The `main` function may be an import, e.g. from an external crate or from the current one.
90+
91+
```rust
92+
mod foo {
93+
pub fn bar() {
94+
println!("Hello, world!");
95+
}
96+
}
97+
use foo::bar as main;
98+
```
99+
89100
> **Note**: Types with implementations of [`Termination`] in the standard library include:
90101
>
91102
> * `()`

0 commit comments

Comments
 (0)