diff --git a/src/api/custom_syntax.rs b/src/api/custom_syntax.rs index 5331eb6a..c22503d2 100644 --- a/src/api/custom_syntax.rs +++ b/src/api/custom_syntax.rs @@ -353,7 +353,7 @@ impl Engine { /// /// * `Ok(None)`: parsing complete and there are no more symbols to match. /// * `Ok(Some(symbol))`: the next symbol to match, which can also be `$expr$`, `$ident$` or `$block$`. - /// * `Err(ParseError)`: error that is reflected back to the [`Engine`], normally `ParseError(ParseErrorType::BadInput(LexError::ImproperSymbol(message)), Position::NONE)` to indicate a syntax error, but it can be any [`ParseError`]. + /// * `Err(ParseError)`: error that is reflected back to the [`Engine`], normally `ParseError(ParseErrorType::BadInput(LexError::ImproperSymbol(message)), Position::NONE)` to indicate a syntax error, but it can be any [`ParseError`][crate::ParseError]. pub fn register_custom_syntax_raw( &mut self, key: impl Into, diff --git a/src/lib.rs b/src/lib.rs index d9e61697..1fcf4cec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,19 +105,19 @@ pub type INT = i64; #[cfg(feature = "only_i32")] pub type INT = i32; -/// The system base integer type. It is defined as [`u64`]. +/// The unsigned system base integer type. It is defined as [`u64`]. /// /// If the `only_i32` feature is enabled, this will be [`u32`] instead. #[cfg(not(feature = "only_i32"))] #[allow(non_camel_case_types)] -type INT_BASE = u64; -/// The system integer base type. +type UNSIGNED_INT = u64; +/// The unsigned system integer base type. /// It is defined as [`u32`] since the `only_i32` feature is used. /// /// If the `only_i32` feature is not used, this will be `u64` instead. #[cfg(feature = "only_i32")] #[allow(non_camel_case_types)] -type INT_BASE = u32; +type UNSIGNED_INT = u32; /// The system floating-point type. It is defined as [`f64`]. /// Not available under `no_float`. @@ -136,8 +136,11 @@ pub type FLOAT = f64; #[cfg(feature = "f32_float")] pub type FLOAT = f32; -pub type ExclusiveRange = std::ops::Range; -pub type InclusiveRange = std::ops::RangeInclusive; +/// An exclusive integer range. +type ExclusiveRange = std::ops::Range; + +/// An inclusive integer range. +type InclusiveRange = std::ops::RangeInclusive; pub use api::custom_syntax::Expression; pub use ast::{FnAccess, AST}; @@ -192,8 +195,11 @@ pub type Array = Vec; #[cfg(not(feature = "no_index"))] pub type Blob = Vec; -/// Hash map of [`Dynamic`] values with [`SmartString`](https://crates.io/crates/smartstring) keys. +/// A dictionary of [`Dynamic`] values with string keys. /// Not available under `no_object`. +/// +/// [`SmartString`](https://crates.io/crates/smartstring) is used as the key type because most +/// property names are ASCII and short, fewer than 23 characters, so they can be stored inline. #[cfg(not(feature = "no_object"))] pub type Map = std::collections::BTreeMap; diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 6b9e3186..0b902666 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -1,7 +1,7 @@ #![allow(non_snake_case)] use crate::plugin::*; -use crate::{def_package, Position, RhaiResultOf, ERR, INT, INT_BASE}; +use crate::{def_package, Position, RhaiResultOf, ERR, INT, UNSIGNED_INT}; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -123,7 +123,7 @@ mod int_functions { .into()); } - INT_BASE::from_str_radix(string.trim(), radix as u32) + UNSIGNED_INT::from_str_radix(string.trim(), radix as u32) .map(|v| v as INT) .map_err(|err| { ERR::ErrorArithmetic( diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 9387bbee..696b05b7 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -5,7 +5,7 @@ use crate::engine::{ KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF, }; use crate::func::native::OnParseTokenCallback; -use crate::{Engine, LexError, StaticVec, INT, INT_BASE}; +use crate::{Engine, LexError, StaticVec, INT, UNSIGNED_INT}; #[cfg(feature = "no_std")] use std::prelude::v1::*; use std::{ @@ -1535,7 +1535,7 @@ fn get_next_token_inner( .filter(|&&c| c != NUMBER_SEPARATOR) .collect(); - INT_BASE::from_str_radix(&out, radix) + UNSIGNED_INT::from_str_radix(&out, radix) .map(|v| v as INT) .map(Token::IntegerConstant) .unwrap_or_else(|_| { diff --git a/src/types/interner.rs b/src/types/interner.rs index f3680a65..a9908cd7 100644 --- a/src/types/interner.rs +++ b/src/types/interner.rs @@ -8,9 +8,8 @@ use std::prelude::v1::*; /// _(internals)_ A factory of identifiers from text strings. /// Exported under the `internals` feature only. /// -/// Normal identifiers are not interned since [`SmartString`][crate::SmartString] and thus copying -/// is relatively fast , this just returns a copy -/// because most identifiers in Rhai are short and ASCII-based. +/// Normal identifiers are not interned since they use `SmartString` because most identifiers in +/// Rhai are short and ASCII-based. Thus copying is relatively fast. /// /// Property getters and setters are interned separately. #[derive(Debug, Clone, Default, Hash)] @@ -24,7 +23,7 @@ pub struct StringsInterner { } impl StringsInterner { - /// Create a new [`IdentifierBuilder`]. + /// Create a new [`StringsInterner`]. #[inline] #[must_use] pub fn new() -> Self {