Skip to content

Commit

Permalink
impl for sized refcell...??
Browse files Browse the repository at this point in the history
  • Loading branch information
meadowsys committed Aug 25, 2024
1 parent ff62c15 commit cd1bf9e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/memory_usage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,27 @@ impl<T: MemoryUsage> MemoryUsage for OnceCell<T> {
}
}

// TODO: this should support `?Sized` but I dunno how to do it without relying
// on refcell internals
impl<T: MemoryUsage> MemoryUsage for RefCell<T> {
mem_use_stack_size_of_impl!();

#[inline]
fn mem_use_heap(&self) -> usize {
T::mem_use_heap(&*self.borrow())
}

#[inline]
fn mem_use_heap_excl_extra_capacity(&self) -> usize {
T::mem_use_heap_excl_extra_capacity(&*self.borrow())
}

#[inline]
fn shrink_extra(&mut self) {
T::shrink_extra(&mut *self.borrow_mut())
}
}

impl MemoryUsage for OsStr {
mem_use_stack_zero_impl!();

Expand Down

0 comments on commit cd1bf9e

Please sign in to comment.