about summary refs log tree commit diff
path: root/src/test/run-pass/thinlto
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-10-22 19:47:05 -0700
committerGitHub <noreply@github.com>2016-10-22 19:47:05 -0700
commitfebfe7683b98ee68a3eca8f069fd09993b3109a3 (patch)
treebc3b5e7d79695d03bd943206ef6523f15c4dec5d /src/test/run-pass/thinlto
parent4845adde360c306624faa3305ea95f95cd11e2b4 (diff)
parent7e603d4e3b2551608a225e115da4e83559b94761 (diff)
downloadrust-febfe7683b98ee68a3eca8f069fd09993b3109a3.tar.gz
rust-febfe7683b98ee68a3eca8f069fd09993b3109a3.zip
Auto merge of #37326 - SimonSapin:from-cow, r=alexcrichton
Implement `From<Cow<str>> for String` and `From<Cow<[T]>> for Vec<T>`.

Motivation: the `selectors` crate is generic over a string type, in order to support all of `String`,  `string_cache::Atom`, and `gecko_string_cache::Atom`. Multiple trait bounds are used for the various operations done with these strings. One of these operations is creating a string (as efficiently as possible, re-using an existing memory allocation if possible) from `Cow<str>`.

The `std::convert::From` trait seems natural for this, but the relevant implementation was missing before this PR. To work around this I’ve added a `FromCowStr` trait in `selectors`, but with trait coherence that means one of `selectors` or `string_cache` needs to depend on the other to implement this trait. Using a trait from `std` would solve this.

The `Vec<T>` implementation is just added for consistency. I also tried a more general `impl<'a, O, B: ?Sized + ToOwned<Owned=O>> From<Cow<'a, B>> for O`, but (the compiler thinks?) it conflicts with `From<T> for T` the impl (after moving all of `collections::borrow` into `core::borrow` to work around trait coherence).
Diffstat (limited to 'src/test/run-pass/thinlto')
0 files changed, 0 insertions, 0 deletions