From 166e3f881fad439bdee97575878d1f494bfb0dd1 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Sun, 12 May 2024 19:32:39 +0200 Subject: [PATCH] Fix usage of spare_capacity_mut which isn't available in MSRV 1.59 --- src/win/drop_target.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/win/drop_target.rs b/src/win/drop_target.rs index 0ec0f8c..aa42259 100644 --- a/src/win/drop_target.rs +++ b/src/win/drop_target.rs @@ -148,15 +148,9 @@ impl DropTarget { for i in 0..item_count { let characters = DragQueryFileW(hdrop, i, null_mut(), 0); let buffer_size = characters as usize + 1; - let mut buffer = Vec::::with_capacity(buffer_size); - - DragQueryFileW( - hdrop, - i, - buffer.spare_capacity_mut().as_mut_ptr().cast(), - buffer_size as u32, - ); - buffer.set_len(buffer_size); + let mut buffer = vec![0u16; buffer_size]; + + DragQueryFileW(hdrop, i, buffer.as_mut_ptr().cast(), buffer_size as u32); paths.push(OsString::from_wide(&buffer[..characters as usize]).into()) }