Skip to content

Commit

Permalink
Merge pull request #4 from balena-io-experimental/job-from-array
Browse files Browse the repository at this point in the history
Allow using array return on compound jobs
  • Loading branch information
pipex authored Oct 29, 2024
2 parents a8df7d3 + 939f067 commit d1a403d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/task/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ impl<S: 'static, E: std::error::Error + 'static> IntoEffect<Vec<Task<S>>, Error>
}
}

impl<S, const N: usize> IntoEffect<Vec<Task<S>>, Error> for [Task<S>; N] {
fn into_effect(self, _: &System) -> Effect<Vec<Task<S>>, Error> {
Effect::of(self.into())
}
}

impl<S: 'static, E: std::error::Error + 'static, const N: usize> IntoEffect<Vec<Task<S>>, Error>
for Result<[Task<S>; N], E>
{
fn into_effect(self, _: &System) -> Effect<Vec<Task<S>>, Error> {
Effect::from(
self.map_err(|e| Error::Other(Box::new(e)))
.map(|a| a.into()),
)
}
}

macro_rules! impl_action_handler {
(
$first:ident, $($ty:ident),*
Expand Down

0 comments on commit d1a403d

Please sign in to comment.