Skip to content

Commit 579130e

Browse files
authored
Fix usage of spare_capacity_mut which isn't available in MSRV 1.59 (#190)
1 parent 45465c5 commit 579130e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/win/drop_target.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,9 @@ impl DropTarget {
148148
for i in 0..item_count {
149149
let characters = DragQueryFileW(hdrop, i, null_mut(), 0);
150150
let buffer_size = characters as usize + 1;
151-
let mut buffer = Vec::<u16>::with_capacity(buffer_size);
152-
153-
DragQueryFileW(
154-
hdrop,
155-
i,
156-
buffer.spare_capacity_mut().as_mut_ptr().cast(),
157-
buffer_size as u32,
158-
);
159-
buffer.set_len(buffer_size);
151+
let mut buffer = vec![0u16; buffer_size];
152+
153+
DragQueryFileW(hdrop, i, buffer.as_mut_ptr().cast(), buffer_size as u32);
160154

161155
paths.push(OsString::from_wide(&buffer[..characters as usize]).into())
162156
}

0 commit comments

Comments
 (0)