Skip to content

Commit

Permalink
Document importing main
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Jan 31, 2024
1 parent a0b1195 commit 50a2c87
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 @@ -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:
>
> * `()`
Expand Down

0 comments on commit 50a2c87

Please sign in to comment.