aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/init.rs
diff options
context:
space:
mode:
authorGravatar Henrik Tjäder <henrik@tjaders.com> 2020-10-13 14:16:33 +0000
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2020-10-15 17:09:27 +0000
commit21253297e4a11a1d9f9c5069578cf9c69a3de31b (patch)
tree896d527bfd204f788eacc3dc791966fb88e287be /macros/src/codegen/init.rs
parent355cb82d0693fe108ac28ec8a0d77e8aab4e6e06 (diff)
downloadrtic-21253297e4a11a1d9f9c5069578cf9c69a3de31b.tar.gz
rtic-21253297e4a11a1d9f9c5069578cf9c69a3de31b.tar.zst
rtic-21253297e4a11a1d9f9c5069578cf9c69a3de31b.zip
Implement all clippy suggestions
Diffstat (limited to 'macros/src/codegen/init.rs')
-rw-r--r--macros/src/codegen/init.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs
index 465a927d..1746bff6 100644
--- a/macros/src/codegen/init.rs
+++ b/macros/src/codegen/init.rs
@@ -8,12 +8,7 @@ use crate::{
codegen::{locals, module, resources_struct, util},
};
-/// Generates support code for `#[init]` functions
-pub fn codegen(
- app: &App,
- analysis: &Analysis,
- extra: &Extra,
-) -> (
+type CodegenResult = (
// mod_app_idle -- the `${init}Resources` constructor
Option<TokenStream2>,
// root_init -- items that must be placed in the root of the crate:
@@ -28,8 +23,11 @@ pub fn codegen(
Vec<TokenStream2>,
// call_init -- the call to the user `#[init]` if there's one
Option<TokenStream2>,
-) {
- if app.inits.len() > 0 {
+);
+
+/// Generates support code for `#[init]` functions
+pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
+ if !app.inits.is_empty() {
let init = &app.inits.first().unwrap();
let mut needs_lt = false;
let name = &init.name;