diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2023-01-10 21:03:10 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:33:30 +0100 |
| commit | d6d58b0eb88242cf63724e1420bd29f8a4489916 (patch) | |
| tree | d797b67b381947cc375d9c89cdc15d0cc98dee1a /macros/src/syntax/parse/software_task.rs | |
| parent | cd790a94286cdc307d399b7f7a43e305e90de5bf (diff) | |
Async tasks can now take arguments at spawn again
Diffstat (limited to 'macros/src/syntax/parse/software_task.rs')
| -rw-r--r-- | macros/src/syntax/parse/software_task.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/macros/src/syntax/parse/software_task.rs b/macros/src/syntax/parse/software_task.rs index fb9b37c..769aa65 100644 --- a/macros/src/syntax/parse/software_task.rs +++ b/macros/src/syntax/parse/software_task.rs @@ -17,7 +17,7 @@ impl SoftwareTask { let name = item.sig.ident.to_string(); if valid_signature { - if let Some(context) = util::parse_inputs(item.sig.inputs, &name) { + if let Some((context, Ok(inputs))) = util::parse_inputs(item.sig.inputs, &name) { let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs); return Ok(SoftwareTask { @@ -25,6 +25,7 @@ impl SoftwareTask { attrs, cfgs, context, + inputs, stmts: item.block.stmts, is_extern: false, }); @@ -33,7 +34,7 @@ impl SoftwareTask { Err(parse::Error::new( span, - format!("this task handler must have type signature `async fn({name}::Context)`"), + format!("this task handler must have type signature `async fn({name}::Context, ..)`"), )) } } @@ -52,7 +53,7 @@ impl SoftwareTask { let name = item.sig.ident.to_string(); if valid_signature { - if let Some(context) = util::parse_inputs(item.sig.inputs, &name) { + if let Some((context, Ok(inputs))) = util::parse_inputs(item.sig.inputs, &name) { let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs); return Ok(SoftwareTask { @@ -60,6 +61,7 @@ impl SoftwareTask { attrs, cfgs, context, + inputs, stmts: Vec::<Stmt>::new(), is_extern: true, }); @@ -68,7 +70,7 @@ impl SoftwareTask { Err(parse::Error::new( span, - format!("this task handler must have type signature `async fn({name}::Context)`"), + format!("this task handler must have type signature `async fn({name}::Context, ..)`"), )) } } |
