Hello,
I use sfml lib that contains type that has Rc<RefCell<>> fields.
I use them in a struct that implements some trait. I have some function
that take trait as argument.
When I compile I have the error : error: cannot pack type `~PtrStruct`,
which does not fulfill `Send`, as a trait bounded by Send
I do some test code to be more clear:
extern mod rsfml;
use std::ptr;
use std::rc::Rc;
use std::cell::RefCell;
pub trait Trait1 {
fn todo(&self);
}
pub struct PtrStruct {
this : Rc<RefCell<~str>>
}
impl Trait1 for PtrStruct {
fn todo(&self) {}
}
pub trait MonTrait {
fn use_mon_trait(&self, tr: ~Trait1);
}
pub struct UseMonTrait;
impl MonTrait for UseMonTrait {
fn use_mon_trait(&self, tr: ~Trait1) {
tr.todo();
}
}
#[main]
fn main() {
let ptr_struct = ~PtrStruct{ this : Rc::new(RefCell::new(~"toto"))};
let use_ptr = UseMonTrait;
use_ptr.use_mon_trait(ptr_struct as ~Trait1);
}
36:34 error: cannot pack type `~PtrStruct`, which does not fulfill
`Send`, as a trait bounded by Send
use_ptr.use_mon_trait(ptr_struct);
^~~~~~~~~~
If I replace Rc<RefCell<~str>> with ~str it works.
Any idea to make Rc<RefCell<>> compatible with Send trait.
Philippe Delrieu
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev