macro_rules! impl_arena_string_common {
($Ty:ident, $Elem:ty) => {
impl<'a, A: allocator_api2::alloc::Allocator + Clone> $Ty<'a, A> {
#[must_use]
pub(crate) const fn new_in(arena: &'a $crate::Arena<A>) -> Self {
Self {
inner: $crate::vec::Vec::new_in(arena),
}
}
#[must_use]
pub(crate) fn with_capacity_in(cap: usize, arena: &'a $crate::Arena<A>) -> Self {
Self {
inner: $crate::vec::Vec::with_capacity_in(cap, arena),
}
}
pub(crate) fn try_with_capacity_in(cap: usize, arena: &'a $crate::Arena<A>) -> Result<Self, allocator_api2::alloc::AllocError> {
Ok(Self {
inner: $crate::vec::Vec::try_with_capacity_in(cap, arena)?,
})
}
#[must_use]
#[inline]
pub const fn len(&self) -> usize {
self.inner.len()
}
#[must_use]
#[inline]
pub const fn is_empty(&self) -> bool {
self.inner.is_empty()
}
#[must_use]
pub const fn capacity(&self) -> usize {
self.inner.capacity()
}
#[inline]
pub fn reserve(&mut self, additional: usize) {
self.inner.reserve(additional);
}
#[inline]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), allocator_api2::alloc::AllocError> {
self.inner.try_reserve(additional)
}
#[inline]
pub fn reserve_exact(&mut self, additional: usize) {
self.inner.reserve_exact(additional);
}
#[inline]
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), allocator_api2::alloc::AllocError> {
self.inner.try_reserve_exact(additional)
}
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit();
}
pub fn shrink_to(&mut self, min_capacity: usize) {
self.inner.shrink_to(min_capacity);
}
pub fn clear(&mut self) {
self.inner.clear();
}
}
impl<A: allocator_api2::alloc::Allocator + Clone> Eq for $Ty<'_, A> {}
impl<A: allocator_api2::alloc::Allocator + Clone> PartialOrd for $Ty<'_, A> {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(Ord::cmp(self, other))
}
}
};
}
pub(crate) use impl_arena_string_common;