Skip to content

Commit 10ca1a4

Browse files
chansukeThomasdezeeuw
authored andcommitted
1 parent fa67e04 commit 10ca1a4

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

tests/socket.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ fn sendfile() {
902902
assert_eq!(n, HELLO_WORLD.data.len());
903903

904904
let mut buf = Vec::with_capacity(HELLO_WORLD.data.len() + 1);
905-
let n = receiver.recv(spare_capacity_mut(&mut buf)).unwrap();
905+
let n = receiver.recv(buf.spare_capacity_mut()).unwrap();
906906
assert_eq!(n, HELLO_WORLD.data.len());
907907
unsafe { buf.set_len(n) };
908908
assert_eq!(buf, HELLO_WORLD.data);
@@ -923,7 +923,7 @@ fn sendfile() {
923923
let mut buf = Vec::with_capacity(LOREM.data.len() + 1);
924924
let mut total = 0;
925925
while total < LOREM.data.len() {
926-
let n = receiver.recv(spare_capacity_mut(&mut buf)).unwrap();
926+
let n = receiver.recv(buf.spare_capacity_mut()).unwrap();
927927
unsafe { buf.set_len(buf.len() + n) };
928928
total += n;
929929
}
@@ -932,7 +932,6 @@ fn sendfile() {
932932
}
933933
}
934934

935-
// TODO: use `Vec::spare_capacity_mut` once stable.
936935
#[cfg(all(
937936
feature = "all",
938937
any(
@@ -942,15 +941,6 @@ fn sendfile() {
942941
target_vendor = "apple",
943942
)
944943
))]
945-
fn spare_capacity_mut(buf: &mut Vec<u8>) -> &mut [MaybeUninit<u8>] {
946-
unsafe {
947-
std::slice::from_raw_parts_mut(
948-
buf.as_mut_ptr().add(buf.len()) as *mut MaybeUninit<u8>,
949-
buf.capacity() - buf.len(),
950-
)
951-
}
952-
}
953-
954944
#[cfg(all(
955945
feature = "all",
956946
any(

0 commit comments

Comments
 (0)