use allocator_api2::alloc::{Allocator, Global};
use crate::arena_str_macros::{impl_str_accessors, impl_str_handle_core, impl_str_read_traits};
use crate::internal::in_chunk::InLocalChunk;
use crate::internal::local_chunk::LocalChunk;
pub struct RcStr<A: Allocator + Clone = Global> {
data: InLocalChunk<u8, A>,
_phantom: core::marker::PhantomData<A>,
}
impl_str_handle_core!(RcStr, Local);
impl_str_accessors!([<A: Allocator + Clone>], RcStr<A>);
impl_str_read_traits!([<A: Allocator + Clone>], RcStr<A>);
impl<A: Allocator + Clone> Drop for RcStr<A> {
#[inline]
fn drop(&mut self) {
let chunk = self.data.chunk_ptr();
unsafe { LocalChunk::dec_ref(chunk) };
}
}
impl<'a, A: Allocator + Clone> ::core::convert::From<crate::strings::String<'a, A>> for RcStr<A> {
#[inline]
fn from(s: crate::strings::String<'a, A>) -> Self {
s.into_arena_str()
}
}
crate::arena_str_macros::impl_from_str_for_slice_handle!(RcStr, Rc, u8);