mirror of
https://github.com/Noratrieb/vechonk.git
synced 2026-03-15 21:56:06 +01:00
fix alignment
This commit is contained in:
parent
9c0cbf6a9c
commit
00f1ba7193
3 changed files with 26 additions and 80 deletions
17
src/iter.rs
17
src/iter.rs
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{RawVechonk, Vechonk};
|
||||
use alloc::boxed::Box;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem;
|
||||
use core::mem::ManuallyDrop;
|
||||
|
||||
/// An iterator over the elements of a [`Vechonk`]
|
||||
pub struct Iter<'a, T: ?Sized> {
|
||||
|
|
@ -105,18 +105,21 @@ pub struct IntoIter<T: ?Sized> {
|
|||
}
|
||||
|
||||
impl<'a, T: ?Sized> IntoIter<T> {
|
||||
pub(super) fn new(chonk: Vechonk<T>) -> IntoIter<T> {
|
||||
let raw = chonk.raw.copy();
|
||||
|
||||
// We don't want to free the memory!
|
||||
mem::forget(chonk);
|
||||
|
||||
pub(crate) fn from_raw(raw: RawVechonk<T>) -> Self {
|
||||
Self {
|
||||
raw,
|
||||
current_index: 0,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn new(chonk: Vechonk<T>) -> IntoIter<T> {
|
||||
// We don't want to free the memory yet!
|
||||
let chonk = ManuallyDrop::new(chonk);
|
||||
let raw = chonk.raw.copy();
|
||||
|
||||
Self::from_raw(raw)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Iterator for IntoIter<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue