Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement std::borrow::Borrow for Atom #89
Conversation
I want to be able to use connect() on Atoms, which requires Borrow<str> be implemented
|
I think this would potentially break hashmaps, but I don’t know how much of a problem that is in practice.
fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V> where K: Borrow<Q>, Q: Hash + Eqwhich, as far as I understand, assume that the |
|
Also, |
Very good point. I didn't even think about this as a side effect. Also, considering the behavior might be changing soon (and the rename from |
|
It’s not as pretty, but something like this would avoid allocating the intermediate vector of that pattern: let mut iter = atoms.iter();
if let Some(first) = iter.next() {
iter.fold(String::new(first), |s, atom| { s.push_str(" "); s.push_str(atom) })
} else {
String::new()
} |
Related to: servo/string-cache#89
Related to: servo/string-cache#89
Related to: servo/string-cache#89
frewsxcv commentedJul 4, 2015
I want to be able to use connect() on Atoms, which requires
Borrow be implemented