|
1 | 1 | use core::alloc::{AllocError, Allocator}; |
2 | 2 | use core::cell::UnsafeCell; |
3 | | -use core::marker::PhantomData; |
| 3 | +use core::fmt::{self, Debug, Formatter}; |
| 4 | +use core::marker::{PhantomData, Unsize}; |
4 | 5 | use core::mem; |
5 | 6 | use core::num::NonZeroUsize; |
6 | | -use core::ops::{Deref, DerefMut}; |
| 7 | +use core::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn}; |
7 | 8 | use core::ptr::{self, NonNull}; |
8 | 9 |
|
| 10 | +use crate::alloc::Global; |
9 | 11 | use crate::raw_rc::rc_layout::{RcLayout, RcLayoutExt}; |
10 | 12 | use crate::raw_rc::rc_value_pointer::RcValuePointer; |
11 | 13 | use crate::raw_rc::{RefCounter, RefCounts}; |
@@ -530,3 +532,35 @@ impl<T, A> RawWeak<[T], A> { |
530 | 532 | Self::allocate_in(length, alloc, super::allocate_zeroed_in::<A, STRONG_COUNT>) |
531 | 533 | } |
532 | 534 | } |
| 535 | + |
| 536 | +impl<T, U, A> CoerceUnsized<RawWeak<U, A>> for RawWeak<T, A> |
| 537 | +where |
| 538 | + T: Unsize<U> + ?Sized, |
| 539 | + U: ?Sized, |
| 540 | +{ |
| 541 | +} |
| 542 | + |
| 543 | +impl<T, A> Debug for RawWeak<T, A> |
| 544 | +where |
| 545 | + T: ?Sized, |
| 546 | +{ |
| 547 | + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { |
| 548 | + f.write_str("(Weak)") |
| 549 | + } |
| 550 | +} |
| 551 | + |
| 552 | +impl<T, A> Default for RawWeak<T, A> |
| 553 | +where |
| 554 | + A: Default, |
| 555 | +{ |
| 556 | + fn default() -> Self { |
| 557 | + Self::new_dangling() |
| 558 | + } |
| 559 | +} |
| 560 | + |
| 561 | +impl<T, U> DispatchFromDyn<RawWeak<U, Global>> for RawWeak<T, Global> |
| 562 | +where |
| 563 | + T: Unsize<U> + ?Sized, |
| 564 | + U: ?Sized, |
| 565 | +{ |
| 566 | +} |
0 commit comments