fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.36k stars 111 forks source link

Why std::borrow::Borrow is not implemented for the collection types? #107

Closed wada314 closed 3 years ago

wada314 commented 3 years ago

Hello, while I'm using the Vecs and Strings of bumpalo, I realized that std::borrow::Borrow trait is not implemented for these types even though std::convert::AsRef is implemented.

I guessed the following state in the Borrow's document might be related, but as far as I checked the code the bumpalo's collections fulfill the condition:

In particular Eq, Ord and Hash must be equivalent for borrowed and owned values: x.borrow() == y.borrow() should give the same result as x == y.

Does anyone know the reason why it is not implemented? thanks,

wada314 commented 3 years ago

My super random guess: std library's impl<T> Borrow<[T]> for Vec<T> is defined in slice.rs, not in vec/mod.rs. Similar for String, it's defined in str.rs but not in string.rs. Maybe forgot to copy these impls when forking the implementations from the std library?

fitzgen commented 3 years ago

Yeah if it wasn't in vec/mod.rs then I probably missed it. Feel free to open a PR adding it!

wada314 commented 3 years ago

Sure I will do it 👍 thank you! 😆