Skip to content

Commit

Permalink
Merge pull request #1461 from clubby789/imported-main
Browse files Browse the repository at this point in the history
Document importing `main`
  • Loading branch information
ehuss committed Mar 20, 2024
2 parents b6779f4 + 50a2c87 commit 824b915
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/crates-and-source-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
>
> * `()`
Expand Down

0 comments on commit 824b915

Please sign in to comment.