parent
d184d3a732
commit
d4f336db40
|
@ -160,7 +160,7 @@ impl<T: Clone> PinnedVec<T> {
|
|||
pub fn reserve_and_pin(&mut self, size: usize) {
|
||||
if self.x.capacity() < size {
|
||||
if self.pinned {
|
||||
unpin(&mut self.x);
|
||||
unpin(self.x.as_mut_ptr());
|
||||
self.pinned = false;
|
||||
}
|
||||
self.x.reserve(size);
|
||||
|
|
|
@ -153,4 +153,12 @@ mod tests {
|
|||
assert_eq!(rv[0].packets.len(), NUM_PACKETS);
|
||||
assert_eq!(rv[1].packets.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_packets_pinning() {
|
||||
let recycler = PacketsRecycler::default();
|
||||
for i in 0..2 {
|
||||
let _first_packets = Packets::new_with_recycler(recycler.clone(), i + 1, "first one");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue