From 6bc011807458fb0b90d3e7ec86ecd05fc3a58e36 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 21 Jul 2022 09:33:49 +0800 Subject: [PATCH] Add FnAccess methods. --- CHANGELOG.md | 1 + src/ast/flags.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a082f37..6c4128e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Enhancements * `EvalContext::eval_expression_tree_raw` and `Expression::eval_with_context_raw` are added to allow for not rewinding the `Scope` at the end of a statements block. * A new `range` function variant that takes an exclusive range with a step. * `as_string` is added to BLOB's to convert it into a string by interpreting it as a UTF-8 byte stream. +* `FnAccess::is_private` and `FnAccess::is_public` are added for convenience. Version 1.8.0 diff --git a/src/ast/flags.rs b/src/ast/flags.rs index 837a9d80..1bd080cb 100644 --- a/src/ast/flags.rs +++ b/src/ast/flags.rs @@ -14,6 +14,27 @@ pub enum FnAccess { Public, } +impl FnAccess { + /// Is this function private? + #[inline(always)] + #[must_use] + pub fn is_private(self) -> bool { + match self { + Self::Private => true, + Self::Public => false, + } + } + /// Is this function public? + #[inline(always)] + #[must_use] + pub fn is_public(self) -> bool { + match self { + Self::Private => false, + Self::Public => true, + } + } +} + bitflags! { /// _(internals)_ Bit-flags containing [`AST`][crate::AST] node configuration options. /// Exported under the `internals` feature only.