From d7960dfe80f19496f35857d98d261cbd13a0f19f Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 21 Dec 2021 13:03:39 +0800 Subject: [PATCH] Short circuit no_function. --- src/func/callable_function.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/func/callable_function.rs b/src/func/callable_function.rs index 251c4d06..65504c42 100644 --- a/src/func/callable_function.rs +++ b/src/func/callable_function.rs @@ -100,10 +100,12 @@ impl CallableFunction { #[inline] #[must_use] pub const fn is_script(&self) -> bool { - match self { - #[cfg(not(feature = "no_function"))] - Self::Script(_) => true, + #[cfg(feature = "no_function")] + return false; + #[cfg(not(feature = "no_function"))] + match self { + Self::Script(_) => true, Self::Pure(_) | Self::Method(_) | Self::Iterator(_) | Self::Plugin(_) => false, } } @@ -123,12 +125,14 @@ impl CallableFunction { #[inline] #[must_use] pub const fn is_native(&self) -> bool { + #[cfg(feature = "no_function")] + return true; + + #[cfg(not(feature = "no_function"))] match self { Self::Pure(_) | Self::Method(_) => true, Self::Plugin(_) => true, Self::Iterator(_) => true, - - #[cfg(not(feature = "no_function"))] Self::Script(_) => false, } } @@ -136,11 +140,13 @@ impl CallableFunction { #[inline] #[must_use] pub fn access(&self) -> FnAccess { + #[cfg(feature = "no_function")] + return FnAccess::Public; + + #[cfg(not(feature = "no_function"))] match self { Self::Plugin(_) => FnAccess::Public, Self::Pure(_) | Self::Method(_) | Self::Iterator(_) => FnAccess::Public, - - #[cfg(not(feature = "no_function"))] Self::Script(f) => f.access, } }