From 6f21ccf7a743a610b282768d735e8284b45a24df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20G=C3=B6tz?= Date: Mon, 27 Nov 2023 14:05:06 +0100 Subject: [PATCH] [refactor] more compact tri-layer apply method --- src/layout.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/layout.rs b/src/layout.rs index ebfc8c5..68114fa 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -343,16 +343,10 @@ struct TriLayer { } impl TriLayer { - fn apply(&self, last_layer: usize, second_to_last_layer: usize) -> Option { - if (last_layer == self.activation_layers.0 - && second_to_last_layer == self.activation_layers.1) - || (last_layer == self.activation_layers.1 - && second_to_last_layer == self.activation_layers.0) - { - Some(self.target_layer) - } else { - None - } + fn apply(&self, layer_0: usize, layer_1: usize) -> Option { + (self.activation_layers == (layer_0, layer_1) + || self.activation_layers == (layer_1, layer_0)) + .then_some(self.target_layer) } }