generic_container/impls/
rc.rs1use core::convert::Infallible;
2use alloc::rc::Rc;
3
4use crate::container_traits::{Container, FragileContainer, FragileTryContainer, TryContainer};
5
6
7impl<T: ?Sized> FragileTryContainer<T> for Rc<T> {
8 type Ref<'a> = &'a T where T: 'a;
9 type RefError = Infallible;
10
11 #[inline]
12 fn new_container(t: T) -> Self where T: Sized {
13 Self::new(t)
14 }
15
16 #[inline]
20 fn into_inner(self) -> Option<T> where T: Sized {
21 Self::into_inner(self)
22 }
23
24 #[inline]
26 fn try_get_ref(&self) -> Result<Self::Ref<'_>, Self::RefError> {
27 Ok(self)
28 }
29}
30
31impl<T: ?Sized> TryContainer<T> for Rc<T> {}
32
33impl<T: ?Sized> FragileContainer<T> for Rc<T> {
34 #[inline]
36 fn get_ref(&self) -> Self::Ref<'_> {
37 self
38 }
39}
40
41impl<T: ?Sized> Container<T> for Rc<T> {}