Browse Source

Use vec! macro to avoid setting vec length manually

pull/95/head
Maccraft123 2 years ago
parent
commit
b6fec34b81
  1. 4
      ctru-rs/src/services/am.rs

4
ctru-rs/src/services/am.rs

@ -78,7 +78,7 @@ impl Am {
pub fn get_title_list(&self, mediatype: FsMediaType) -> crate::Result<Vec<Title>> { pub fn get_title_list(&self, mediatype: FsMediaType) -> crate::Result<Vec<Title>> {
let count = self.get_title_count(mediatype)?; 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; let mut read_amount = 0;
unsafe { unsafe {
ResultCode(ctru_sys::AM_GetTitleList( ResultCode(ctru_sys::AM_GetTitleList(
@ -87,8 +87,6 @@ impl Am {
count, count,
buf.as_mut_ptr(), buf.as_mut_ptr(),
))?; ))?;
buf.set_len(read_amount as usize);
} }
Ok(buf Ok(buf
.into_iter() .into_iter()

Loading…
Cancel
Save