The allocator_api2 crate exposes Rust's Allocator trait, which is an experimental trait for defining allocators.
It would be interesting if we were able to take advantage of the Allocator trait with a Collector super trait of our own. Something akin to:
trait Collector : Allocator {
// Methods to be determined.
}
This would mean that we could use third party collection libraries that expose an allocator API of their own.
Potential concerns
- Is doing this even possible in a generic way across multiple collectors?
- Is it even safe to do this and use collections that may not be properly designed for this use case?