From b15e0a279b17d29a3fa6408b76da35f0b843ce21 Mon Sep 17 00:00:00 2001
From: mo8it <mo8it@proton.me>
Date: Tue, 9 Apr 2024 21:23:02 +0200
Subject: [PATCH] Use shrink to fit before leaking the vector

---
 src/main.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 62bfd98b..504c02dc 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")?;