deepsize icon indicating copy to clipboard operation
deepsize copied to clipboard

Standard library types

Open dtolnay opened this issue 6 years ago • 5 comments

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?

dtolnay avatar Feb 17 '19 21:02 dtolnay

I wouldn't try to be exhaustive. People can send PRs for additional impls as they are needed.

dtolnay avatar Feb 17 '19 21:02 dtolnay

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.

Aeledfyr avatar Mar 31 '19 15:03 Aeledfyr

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.

dtolnay avatar Mar 31 '19 17:03 dtolnay

I'd love to see BTreeSet and BTreeMap supported.

droundy avatar Nov 01 '19 12:11 droundy

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.

Aeledfyr avatar Oct 02 '20 23:10 Aeledfyr