From 903b6d6795a846464bc37fd8e1a213177a8b102b Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 28 Jan 2021 16:59:19 +0800 Subject: [PATCH] Rename set_doc_comments to enable_doc_comments. --- RELEASES.md | 1 + src/engine.rs | 9 +++++++-- src/engine_settings.rs | 2 +- src/fn_func.rs | 1 + tests/comments.rs | 10 +++++----- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 90876d33..3d57b32e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -13,6 +13,7 @@ Breaking changes * Rust compiler requirement raised to 1.49. * `NativeCallContext::new` taker an additional parameter containing the name of the function called. +* `Engine::set_doc_comments` is renamed `Engine::enable_doc_comments`. Bug fixes --------- diff --git a/src/engine.rs b/src/engine.rs index 150a8eb5..21f65fa3 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -545,32 +545,37 @@ impl State { #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct Limits { /// Maximum levels of call-stack to prevent infinite recursion. - /// Not available under `no_function`. /// /// Set to zero to effectively disable function calls. + /// + /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] pub max_call_stack_depth: usize, /// Maximum depth of statements/expressions at global level. pub max_expr_depth: Option, /// Maximum depth of statements/expressions in functions. + /// /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] pub max_function_expr_depth: Option, /// Maximum number of operations allowed to run. pub max_operations: Option, /// Maximum number of [modules][Module] allowed to load. - /// Not available under `no_module`. /// /// Set to zero to effectively disable loading any [module][Module]. + /// + /// Not available under `no_module`. #[cfg(not(feature = "no_module"))] pub max_modules: usize, /// Maximum length of a [string][ImmutableString]. pub max_string_size: Option, /// Maximum length of an [array][Array]. + /// /// Not available under `no_index`. #[cfg(not(feature = "no_index"))] pub max_array_size: Option, /// Maximum number of properties in an [object map][Map]. + /// /// Not available under `no_object`. #[cfg(not(feature = "no_object"))] pub max_map_size: Option, diff --git a/src/engine_settings.rs b/src/engine_settings.rs index 396c155e..7d36b5da 100644 --- a/src/engine_settings.rs +++ b/src/engine_settings.rs @@ -34,7 +34,7 @@ impl Engine { } /// Enable/disable doc-comments. #[inline(always)] - pub fn set_doc_comments(&mut self, enable: bool) -> &mut Self { + pub fn enable_doc_comments(&mut self, enable: bool) -> &mut Self { self.disable_doc_comments = !enable; self } diff --git a/src/fn_func.rs b/src/fn_func.rs index 22eadf5f..aea3923e 100644 --- a/src/fn_func.rs +++ b/src/fn_func.rs @@ -8,6 +8,7 @@ use crate::stdlib::{boxed::Box, string::ToString}; use crate::{Engine, EvalAltResult, ParseError, Scope, AST}; /// Trait to create a Rust closure from a script. +/// /// Not available under `no_function`. pub trait Func { type Output; diff --git a/tests/comments.rs b/tests/comments.rs index 81aa2369..72f64aed 100644 --- a/tests/comments.rs +++ b/tests/comments.rs @@ -12,10 +12,10 @@ fn test_comments() -> Result<(), Box> { assert_eq!( engine.eval::( r#" - let /* I am a - multi-line - comment, yay! - */ x = 42; x + let /* I am a + multi-line + comment, yay! + */ x = 42; x "# )?, 42 @@ -88,7 +88,7 @@ fn test_comments_doc() -> Result<(), Box> { ) .is_err()); - engine.set_doc_comments(false); + engine.enable_doc_comments(false); engine.compile( r"