Closed
Description
The following doesn't compile, but I believe it should:
use std::borrow::{ToOwned, Cow};
fn main() {
assert_send(Cow::Borrowed("foo"));
}
fn assert_send<T: Send>(_: T) {}
Error:
cow.rs:4:3: 4:14 error: the trait `core::marker::Send` is not implemented for the type `<str as collections::borrow::ToOwned>::Owned` [E0277]
cow.rs:4 assert_send(Cow::Borrowed("foo"));
^~~~~~~~~~~
cow.rs:4:3: 4:14 note: `<str as collections::borrow::ToOwned>::Owned` cannot be sent between threads safely
cow.rs:4 assert_send(Cow::Borrowed("foo"));
^~~~~~~~~~~
error: aborting due to previous error
Even though <str as ToOwned>::Owned == String
, and String: Send
. In fact, this compiles:
assert_send("foo");
assert_send("foo".to_owned());
rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-20)