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