From 21253297e4a11a1d9f9c5069578cf9c69a3de31b Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 13 Oct 2020 14:16:33 +0000 Subject: Implement all clippy suggestions --- macros/src/codegen/init.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'macros/src/codegen/init.rs') 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, // root_init -- items that must be placed in the root of the crate: @@ -28,8 +23,11 @@ pub fn codegen( Vec, // call_init -- the call to the user `#[init]` if there's one Option, -) { - 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; -- cgit v1.2.3