From b6fec34b817777a4d6a0fd80a2fc09f0036b4c46 Mon Sep 17 00:00:00 2001 From: Maccraft123 Date: Fri, 3 Mar 2023 17:18:42 +0100 Subject: [PATCH] Use vec! macro to avoid setting vec length manually --- ctru-rs/src/services/am.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ctru-rs/src/services/am.rs b/ctru-rs/src/services/am.rs index 5a52b99..100b5fa 100644 --- a/ctru-rs/src/services/am.rs +++ b/ctru-rs/src/services/am.rs @@ -78,7 +78,7 @@ impl Am { pub fn get_title_list(&self, mediatype: FsMediaType) -> crate::Result> { let count = self.get_title_count(mediatype)?; - let mut buf = Vec::with_capacity(count as usize); + let mut buf = vec![0; count as usize]; let mut read_amount = 0; unsafe { ResultCode(ctru_sys::AM_GetTitleList( @@ -87,8 +87,6 @@ impl Am { count, buf.as_mut_ptr(), ))?; - - buf.set_len(read_amount as usize); } Ok(buf .into_iter()