Fix doc test.

This commit is contained in:
Stephen Chung 2021-11-09 15:42:17 +08:00
parent f6dc440601
commit 93869b544c
2 changed files with 5 additions and 1 deletions

View File

@ -780,6 +780,7 @@ impl AST {
/// let mut iter = ast.iter_literal_variables(true, false) /// let mut iter = ast.iter_literal_variables(true, false)
/// .map(|(name, is_const, value)| (name, is_const, value.as_int().unwrap())); /// .map(|(name, is_const, value)| (name, is_const, value.as_int().unwrap()));
/// ///
/// # #[cfg(not(feature = "no_optimize"))]
/// assert_eq!(iter.next(), Some(("A", true, 42))); /// assert_eq!(iter.next(), Some(("A", true, 42)));
/// assert_eq!(iter.next(), Some(("C", true, 999))); /// assert_eq!(iter.next(), Some(("C", true, 999)));
/// assert_eq!(iter.next(), None); /// assert_eq!(iter.next(), None);
@ -793,6 +794,7 @@ impl AST {
/// let mut iter = ast.iter_literal_variables(true, true) /// let mut iter = ast.iter_literal_variables(true, true)
/// .map(|(name, is_const, value)| (name, is_const, value.as_int().unwrap())); /// .map(|(name, is_const, value)| (name, is_const, value.as_int().unwrap()));
/// ///
/// # #[cfg(not(feature = "no_optimize"))]
/// assert_eq!(iter.next(), Some(("A", true, 42))); /// assert_eq!(iter.next(), Some(("A", true, 42)));
/// assert_eq!(iter.next(), Some(("b", false, 123))); /// assert_eq!(iter.next(), Some(("b", false, 123)));
/// assert_eq!(iter.next(), Some(("C", true, 999))); /// assert_eq!(iter.next(), Some(("C", true, 999)));

View File

@ -2070,9 +2070,11 @@ impl Engine {
pub fn optimize_ast( pub fn optimize_ast(
&self, &self,
scope: &Scope, scope: &Scope,
mut ast: AST, ast: AST,
optimization_level: crate::OptimizationLevel, optimization_level: crate::OptimizationLevel,
) -> AST { ) -> AST {
let mut ast = ast;
#[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_function"))]
let lib = ast let lib = ast
.lib() .lib()