rust/src/libcollectionstest
Simon Sapin 7e603d4e3b 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).
2016-10-21 17:42:29 +02:00
..
btree Address FIXME in libcollectionstest/btree/set.rs 2016-08-28 18:52:21 -04:00
bench.rs More test fixes 2015-04-14 10:14:19 -07:00
binary_heap.rs std: Stabilize and deprecate APIs for 1.13 2016-10-03 10:34:34 -07:00
cow_str.rs impl {Add, AddAssign}<{str, Cow<str>}> for Cow<str> 2016-09-29 14:56:58 +02:00
enum_set.rs format with [rustfmt_skip] and addressed a few comments 2016-05-24 07:39:55 +05:30
fmt.rs std: Clean out #[deprecated] APIs 2015-03-31 15:49:57 -07:00
lib.rs Auto merge of #36743 - SimonSapin:dedup-by, r=alexcrichton 2016-10-13 19:56:53 -07:00
linked_list.rs run rustfmt on libcollections test module 2016-05-22 23:57:13 +05:30
slice.rs Auto merge of #36743 - SimonSapin:dedup-by, r=alexcrichton 2016-10-13 19:56:53 -07:00
str.rs Rollup merge of #36699 - bluss:repeat-str, r=alexcrichton 2016-10-11 17:51:26 +02:00
string.rs Implement From<Cow<str>> for String and From<Cow<[T]>> for Vec<T>. 2016-10-21 17:42:29 +02:00
vec.rs Implement From<Cow<str>> for String and From<Cow<[T]>> for Vec<T>. 2016-10-21 17:42:29 +02:00
vec_deque.rs Rename static mut to upper case 2016-10-14 17:21:11 +03:00