summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-09 21:23:02 +0200
committermo8it <mo8it@proton.me>2024-04-09 21:23:02 +0200
commitb15e0a279b17d29a3fa6408b76da35f0b843ce21 (patch)
treebfffbb7538d3b282c66671b985bdf8d3d131d532 /src/main.rs
parent787bec9875ec3e76d5870808cc7299da1d26dea6 (diff)
Use shrink to fit before leaking the vector
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 62bfd98..504c02d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -85,8 +85,10 @@ Did you already install Rust?
Try running `cargo --version` to diagnose the problem.",
)?;
- // Leaking is not a problem since the exercises are used until the end of the program.
- let exercises = InfoFile::parse()?.exercises.leak();
+ let mut info_file = InfoFile::parse()?;
+ info_file.exercises.shrink_to_fit();
+ // Leaking is not a problem since the exercises' slice is used until the end of the program.
+ let exercises = info_file.exercises.leak();
if matches!(args.command, Some(Subcommands::Init)) {
init::init(exercises).context("Initialization failed")?;