Use shrink to fit before leaking the vector

This commit is contained in:
mo8it 2024-04-09 21:23:02 +02:00
parent 787bec9875
commit b15e0a279b

View file

@ -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")?;