@@ -13,6 +13,7 @@ use std::hash::Hash;
13
13
use std:: marker:: PhantomData ;
14
14
use std:: mem:: { size_of, align_of} ;
15
15
use std:: net:: { Ipv4Addr , Ipv6Addr } ;
16
+ use std:: ops:: { Range , RangeFrom , RangeFull , RangeTo } ;
16
17
use std:: os:: raw:: c_void;
17
18
use std:: sync:: Arc ;
18
19
use std:: sync:: atomic:: { AtomicBool , AtomicIsize , AtomicUsize } ;
@@ -304,6 +305,33 @@ impl<K: HeapSizeOf, V: HeapSizeOf> HeapSizeOf for BTreeMap<K, V> {
304
305
}
305
306
}
306
307
308
+ impl < T > HeapSizeOf for Range < T >
309
+ where
310
+ T : HeapSizeOf ,
311
+ {
312
+ fn heap_size_of_children ( & self ) -> usize {
313
+ self . start . heap_size_of_children ( ) + self . end . heap_size_of_children ( )
314
+ }
315
+ }
316
+
317
+ impl < T > HeapSizeOf for RangeFrom < T >
318
+ where
319
+ T : HeapSizeOf ,
320
+ {
321
+ fn heap_size_of_children ( & self ) -> usize {
322
+ self . start . heap_size_of_children ( )
323
+ }
324
+ }
325
+
326
+ impl < T > HeapSizeOf for RangeTo < T >
327
+ where
328
+ T : HeapSizeOf ,
329
+ {
330
+ fn heap_size_of_children ( & self ) -> usize {
331
+ self . end . heap_size_of_children ( )
332
+ }
333
+ }
334
+
307
335
/// For use on types defined in external crates
308
336
/// with known heap sizes.
309
337
#[ macro_export]
@@ -335,4 +363,4 @@ known_heap_size!(0, u8, u16, u32, u64, usize);
335
363
known_heap_size ! ( 0 , i8 , i16 , i32 , i64 , isize ) ;
336
364
known_heap_size ! ( 0 , bool , f32 , f64 ) ;
337
365
known_heap_size ! ( 0 , AtomicBool , AtomicIsize , AtomicUsize ) ;
338
- known_heap_size ! ( 0 , Ipv4Addr , Ipv6Addr ) ;
366
+ known_heap_size ! ( 0 , Ipv4Addr , Ipv6Addr , RangeFull ) ;
0 commit comments