From 579130ecb4f9f315ae52190af42f0ea46aeaa4a2 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz <6529475+prokopyl@users.noreply.github.com> Date: Thu, 23 May 2024 01:54:39 +0200 Subject: [PATCH] Fix usage of spare_capacity_mut which isn't available in MSRV 1.59 (#190) --- 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()) }