Add FnNamespace methods.

This commit is contained in:
Stephen Chung 2022-07-21 09:36:11 +08:00
parent 6bc0118074
commit f85ad28e93
2 changed files with 22 additions and 1 deletions

View File

@ -32,7 +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.
* `FnAccess::is_private`, `FnAccess::is_public`, `FnNamespace::is_module_namespace` and `FnNameSpace::is_global_namespace` are added for convenience.
Version 1.8.0

View File

@ -32,6 +32,27 @@ pub enum FnNamespace {
Global,
}
impl FnNamespace {
/// Is this a module namespace?
#[inline(always)]
#[must_use]
pub fn is_module_namespace(self) -> bool {
match self {
Self::Internal => true,
Self::Global => false,
}
}
/// Is this a global namespace?
#[inline(always)]
#[must_use]
pub fn is_global_namespace(self) -> bool {
match self {
Self::Internal => false,
Self::Global => true,
}
}
}
/// A type containing all metadata for a registered function.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[non_exhaustive]