From b268b8e8ac396aa93f21629cc3276e0cb1a8be00 Mon Sep 17 00:00:00 2001 From: spuds <71292624+bananaturtlesandwich@users.noreply.github.com> Date: Wed, 11 Jan 2023 10:25:53 +0000 Subject: [PATCH] hashbrown's hashmap with_capacity no work >:/ --- src/pak.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pak.rs b/src/pak.rs index e0fe0f5..898a4fa 100644 --- a/src/pak.rs +++ b/src/pak.rs @@ -10,6 +10,7 @@ pub struct Pak { pub version: Version, pub footer: super::Footer, pub mount_point: String, + pub entries: hashbrown::HashMap, } impl Pak { @@ -21,17 +22,19 @@ impl Pak { let footer = super::Footer::new(&mut reader, version)?; reader.seek(io::SeekFrom::Start(footer.offset))?; let mount_point = reader.read_string()?; - let mut entries = hashbrown::HashMap::with_capacity(reader.read_u32::()? as usize); - for _ in 0..entries.capacity() { + let len = reader.read_u32::()? as usize; + let mut entries = hashbrown::HashMap::with_capacity(len); + for _ in 0..len { entries.insert( - dbg!(reader.read_string()?), - dbg!(super::Entry::new(&mut reader, version)?), + reader.read_string()?, + super::Entry::new(&mut reader, version)?, ); } Ok(Self { version, footer, mount_point, + entries, }) } }