associated types ftw thanks gustav

This commit is contained in:
Graham Christensen 2017-11-06 13:08:24 -05:00
parent d559383737
commit 6abdbb5597
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 5 additions and 2 deletions

View file

@ -60,7 +60,9 @@ struct BuildWorker {
}
impl worker::SimpleWorker for BuildWorker {
fn consumer<BuildJob>(&self, job: BuildJob, resp: Actions) -> Result<(), Error> {
type J = BuildJob;
fn consumer(&self, job: BuildJob, resp: Actions) -> Result<(), Error> {
let project = self.cloner.project(job.repo.full_name, job.repo.clone_url);
let co = project.clone_for("builder".to_string(),
job.pr.number.to_string())?;

View file

@ -23,7 +23,8 @@ pub struct Actions {
}
pub trait SimpleWorker {
fn consumer<J>(&self, job: J, resp: Actions) -> Result<(), Error>;
type J;
fn consumer(&self, job: Self::J, resp: Actions) -> Result<(), Error>;
}
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {