Skip to content

Commit

Permalink
extra: change workcache::Work::unwrap to move out of self.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Jul 23, 2013
1 parent d5803e6 commit 9a093ab
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,37 +330,29 @@ impl<T:Send +
pub fn new(p: @mut Prep, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
Work { prep: p, res: Some(e) }
}
}

// FIXME (#3724): movable self. This should be in impl Work.
fn unwrap<T:Send +
Encodable<json::Encoder> +
Decodable<json::Decoder>>( // FIXME(#5121)
w: Work<T>) -> T {
let mut ww = w;
let s = ww.res.take();

match s {
None => fail!(),
Some(Left(v)) => v,
Some(Right(port)) => {
let (exe, v) = recv_one(port);

let s = json_encode(&v);

let p = &*ww.prep;
do p.ctxt.db.write |db| {
db.cache(p.fn_name,
&p.declared_inputs,
&exe.discovered_inputs,
&exe.discovered_outputs,
s);
pub fn unwrap(self) -> T {
let Work { prep, res } = self;
match res {
None => fail!(),
Some(Left(v)) => v,
Some(Right(port)) => {
let (exe, v) = recv_one(port);
let s = json_encode(&v);
do prep.ctxt.db.write |db| {
db.cache(prep.fn_name,
&prep.declared_inputs,
&exe.discovered_inputs,
&exe.discovered_outputs,
s);
}
v
}
v
}
}
}


//#[test]
fn test() {
use std::io::WriterUtil;
Expand All @@ -385,6 +377,6 @@ fn test() {
out.to_str()
}
};
let s = unwrap(w);
let s = w.unwrap();
io::println(s);
}

0 comments on commit 9a093ab

Please sign in to comment.