From 865c84b3d3410bc862ed1c29ee13d65938aea590 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 30 Jan 2024 18:13:16 +0000 Subject: [PATCH] Document importing `main` --- src/crates-and-source-files.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/crates-and-source-files.md b/src/crates-and-source-files.md index 8d54c3f6b..4b94c4c04 100644 --- a/src/crates-and-source-files.md +++ b/src/crates-and-source-files.md @@ -119,6 +119,17 @@ fn main() -> impl std::process::Termination { } ``` +The `main` function may be a re-export, 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: > > * `()`