1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-09-16 10:51:42 +02:00

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