Allow non-custom reserved symbols in custom syntax.

This commit is contained in:
Stephen Chung
2021-12-16 18:01:49 +08:00
parent f92cbe1f6d
commit fbc2b1f13d
8 changed files with 77 additions and 60 deletions

View File

@@ -1,8 +1,8 @@
//! Module containing all deprecated API that will be removed in the next major version.
use crate::{
Dynamic, Engine, EvalAltResult, FnPtr, ImmutableString, NativeCallContext, RhaiResult, Scope,
AST,
Dynamic, Engine, EvalAltResult, Expression, FnPtr, ImmutableString, NativeCallContext,
RhaiResult, Scope, AST,
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
@@ -304,3 +304,19 @@ impl FnPtr {
self.call_raw(context, this_ptr, arg_values)
}
}
impl Expression<'_> {
/// If this expression is a variable name, return it. Otherwise [`None`].
///
/// # Deprecated
///
/// This method is deprecated. Use [`get_string_value`][Expression::get_string_value] instead.
///
/// This method will be removed in the next major version.
#[deprecated(since = "1.4.0", note = "use `get_string_value` instead")]
#[inline(always)]
#[must_use]
pub fn get_variable_name(&self) -> Option<&str> {
self.get_string_value()
}
}