deepsize
deepsize copied to clipboard
Standard library types
Moved from https://github.com/dtolnay/request-for-implementation/issues/22#issuecomment-457410613:
Does anyone have preferences on which standard library types this is implemented for?
I wouldn't try to be exhaustive. People can send PRs for additional impls as they are needed.
Here is the current list of standard library types which I have implemented:
-
Vec
,VecDequeue
,LinkedList
-
HashMap
,HashSet
-
Box
-
Arc
,Rc
-
&T
,[T]
,[T; 1-32]
-
String
-
Option<T>
,Result<R, E>
-
std::marker::PhantomData
-
()
,bool
,char
,str
, number types, atomic integers
It would be nice if I could use the derive macro on foreign types, but since that doesn't work, if something doesn't allocate, I can just use known_deep_size!(0, ...)
to implement it.
Are there any common collection or heap allocation types that I'm missing? One of the best ways to find what's missing would probably be to try to use it somewhere.
That seems like a good list to me! I would start with that and wait for users to report any additional types that they need support for.
I'd love to see BTreeSet
and BTreeMap
supported.
BTreeSet
and BTreeMap
are now implemented, along with all atomic integers and NonZero
integers. I've also added some additional library support, and:
Mutability wrappers: Cell<T: Copy>
, RefCell<T>
, Mutex<T>
, & RwLock<T>
Weak reference counted pointers: rc::Weak<T>
and sync::Weak<T>
I haven't implemented them yet, but I'm considering adding Path
and PathBuf
.