Implement generalized object and type parameter bounds (Fixes #16462)

This commit is contained in:
Niko Matsakis 2014-08-27 21:46:52 -04:00
parent 3ee047ae1f
commit 1b487a8906
272 changed files with 6783 additions and 3154 deletions

View file

@ -103,7 +103,7 @@ pub struct Task {
pub name: Option<SendStr>,
state: TaskState,
imp: Option<Box<Runtime + Send>>,
imp: Option<Box<Runtime + Send + 'static>>,
}
// Once a task has entered the `Armed` state it must be destroyed via `drop`,
@ -353,14 +353,14 @@ impl Task {
/// Inserts a runtime object into this task, transferring ownership to the
/// task. It is illegal to replace a previous runtime object in this task
/// with this argument.
pub fn put_runtime(&mut self, ops: Box<Runtime + Send>) {
pub fn put_runtime(&mut self, ops: Box<Runtime + Send + 'static>) {
assert!(self.imp.is_none());
self.imp = Some(ops);
}
/// Removes the runtime from this task, transferring ownership to the
/// caller.
pub fn take_runtime(&mut self) -> Box<Runtime + Send> {
pub fn take_runtime(&mut self) -> Box<Runtime + Send + 'static> {
assert!(self.imp.is_some());
self.imp.take().unwrap()
}
@ -390,7 +390,7 @@ impl Task {
Ok(t) => Some(t),
Err(t) => {
let data = mem::transmute::<_, raw::TraitObject>(t).data;
let obj: Box<Runtime + Send> =
let obj: Box<Runtime + Send + 'static> =
mem::transmute(raw::TraitObject {
vtable: vtable,
data: data,