Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit edb01f1

Browse files
committed
Box the CLI command futures to reduce the size of the try_main future
1 parent eff6672 commit edb01f1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

crates/cli/src/commands/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,18 @@ pub struct Options {
6969
impl Options {
7070
pub async fn run(self, figment: &Figment) -> anyhow::Result<()> {
7171
use Subcommand as S;
72+
// We Box the futures for each subcommand so that we avoid this function being
73+
// big on the stack all the time
7274
match self.subcommand {
73-
Some(S::Config(c)) => c.run(figment).await,
74-
Some(S::Database(c)) => c.run(figment).await,
75-
Some(S::Server(c)) => c.run(figment).await,
76-
Some(S::Worker(c)) => c.run(figment).await,
77-
Some(S::Manage(c)) => c.run(figment).await,
78-
Some(S::Templates(c)) => c.run(figment).await,
79-
Some(S::Debug(c)) => c.run(figment).await,
80-
Some(S::Doctor(c)) => c.run(figment).await,
81-
None => self::server::Options::default().run(figment).await,
75+
Some(S::Config(c)) => Box::pin(c.run(figment)).await,
76+
Some(S::Database(c)) => Box::pin(c.run(figment)).await,
77+
Some(S::Server(c)) => Box::pin(c.run(figment)).await,
78+
Some(S::Worker(c)) => Box::pin(c.run(figment)).await,
79+
Some(S::Manage(c)) => Box::pin(c.run(figment)).await,
80+
Some(S::Templates(c)) => Box::pin(c.run(figment)).await,
81+
Some(S::Debug(c)) => Box::pin(c.run(figment)).await,
82+
Some(S::Doctor(c)) => Box::pin(c.run(figment)).await,
83+
None => Box::pin(self::server::Options::default().run(figment)).await,
8284
}
8385
}
8486

0 commit comments

Comments
 (0)