#![expect(
clippy::items_after_statements,
clippy::single_match_else,
clippy::panic,
clippy::manual_assert,
clippy::undocumented_unsafe_blocks,
clippy::match_wild_err_arm,
clippy::missing_panics_doc,
clippy::manual_saturating_arithmetic,
clippy::struct_field_names,
reason = "reachable panics are programmer error; keep this close to `allocator_api2::vec::Vec`; `drain_*` names mirror `std::vec::Drain`"
)]
use core::ptr::NonNull;
use allocator_api2::alloc::{Allocator, Global};
use allocator_api2::vec::IntoIter as ApiIntoIter;
use crate::Arena;
mod basic;
mod buffer;
mod collect_in;
mod drain;
mod freeze;
mod from_iterator_in;
mod mutate;
mod traits;
mod vec_macro;
pub use collect_in::CollectIn;
pub use drain::Drain;
pub use from_iterator_in::FromIteratorIn;
#[doc(inline)]
pub use crate::__multitude_vec as vec;
pub struct Vec<'a, T, A: Allocator + Clone = Global> {
arena: &'a Arena<A>,
data: NonNull<T>,
len: usize,
cap: usize,
}
pub type IntoIter<'a, T, A> = ApiIntoIter<T, &'a Arena<A>>;
impl<T, A: Allocator + Clone> Drop for Vec<'_, T, A> {
fn drop(&mut self) {
struct DeallocateGuard<'g, 'a, T, A: Allocator + Clone> {
v: &'g mut Vec<'a, T, A>,
}
impl<T, A: Allocator + Clone> Drop for DeallocateGuard<'_, '_, T, A> {
fn drop(&mut self) {
Vec::deallocate_buffer(self.v.arena, self.v.data, self.v.cap);
}
}
let g = DeallocateGuard { v: self };
g.v.clear();
}
}