mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
27 lines
432 B
Rust
27 lines
432 B
Rust
use std::cell::RefCell;
|
|
use std::rc::Rc;
|
|
|
|
trait Foo {
|
|
fn set(&mut self, v: Rc<RefCell<A>>);
|
|
}
|
|
|
|
struct B {
|
|
v: Option<Rc<RefCell<A>>>
|
|
}
|
|
|
|
impl Foo for B {
|
|
fn set(&mut self, v: Rc<RefCell<A>>)
|
|
{
|
|
self.v = Some(v);
|
|
}
|
|
}
|
|
|
|
struct A {
|
|
v: Box<dyn Foo + Send>,
|
|
}
|
|
|
|
fn main() {
|
|
let a = A {v: Box::new(B{v: None}) as Box<dyn Foo + Send>};
|
|
//~^ ERROR `Rc<RefCell<A>>` cannot be sent between threads safely
|
|
}
|