Fix doc comments.

This commit is contained in:
Stephen Chung 2021-12-31 23:01:34 +08:00
parent 7ed91eadc0
commit 8329baea29
5 changed files with 21 additions and 16 deletions

View File

@ -353,7 +353,7 @@ impl Engine {
/// ///
/// * `Ok(None)`: parsing complete and there are no more symbols to match. /// * `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$`. /// * `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( pub fn register_custom_syntax_raw(
&mut self, &mut self,
key: impl Into<Identifier>, key: impl Into<Identifier>,

View File

@ -105,19 +105,19 @@ pub type INT = i64;
#[cfg(feature = "only_i32")] #[cfg(feature = "only_i32")]
pub type INT = 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. /// If the `only_i32` feature is enabled, this will be [`u32`] instead.
#[cfg(not(feature = "only_i32"))] #[cfg(not(feature = "only_i32"))]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
type INT_BASE = u64; type UNSIGNED_INT = u64;
/// The system integer base type. /// The unsigned system integer base type.
/// It is defined as [`u32`] since the `only_i32` feature is used. /// 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. /// If the `only_i32` feature is not used, this will be `u64` instead.
#[cfg(feature = "only_i32")] #[cfg(feature = "only_i32")]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
type INT_BASE = u32; type UNSIGNED_INT = u32;
/// The system floating-point type. It is defined as [`f64`]. /// The system floating-point type. It is defined as [`f64`].
/// Not available under `no_float`. /// Not available under `no_float`.
@ -136,8 +136,11 @@ pub type FLOAT = f64;
#[cfg(feature = "f32_float")] #[cfg(feature = "f32_float")]
pub type FLOAT = f32; pub type FLOAT = f32;
pub type ExclusiveRange = std::ops::Range<INT>; /// An exclusive integer range.
pub type InclusiveRange = std::ops::RangeInclusive<INT>; type ExclusiveRange = std::ops::Range<INT>;
/// An inclusive integer range.
type InclusiveRange = std::ops::RangeInclusive<INT>;
pub use api::custom_syntax::Expression; pub use api::custom_syntax::Expression;
pub use ast::{FnAccess, AST}; pub use ast::{FnAccess, AST};
@ -192,8 +195,11 @@ pub type Array = Vec<Dynamic>;
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
pub type Blob = Vec<u8>; pub type Blob = Vec<u8>;
/// 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`. /// 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"))] #[cfg(not(feature = "no_object"))]
pub type Map = std::collections::BTreeMap<Identifier, Dynamic>; pub type Map = std::collections::BTreeMap<Identifier, Dynamic>;

View File

@ -1,7 +1,7 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use crate::plugin::*; 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")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
@ -123,7 +123,7 @@ mod int_functions {
.into()); .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(|v| v as INT)
.map_err(|err| { .map_err(|err| {
ERR::ErrorArithmetic( ERR::ErrorArithmetic(

View File

@ -5,7 +5,7 @@ use crate::engine::{
KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF, KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF,
}; };
use crate::func::native::OnParseTokenCallback; 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")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
use std::{ use std::{
@ -1535,7 +1535,7 @@ fn get_next_token_inner(
.filter(|&&c| c != NUMBER_SEPARATOR) .filter(|&&c| c != NUMBER_SEPARATOR)
.collect(); .collect();
INT_BASE::from_str_radix(&out, radix) UNSIGNED_INT::from_str_radix(&out, radix)
.map(|v| v as INT) .map(|v| v as INT)
.map(Token::IntegerConstant) .map(Token::IntegerConstant)
.unwrap_or_else(|_| { .unwrap_or_else(|_| {

View File

@ -8,9 +8,8 @@ use std::prelude::v1::*;
/// _(internals)_ A factory of identifiers from text strings. /// _(internals)_ A factory of identifiers from text strings.
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
/// ///
/// Normal identifiers are not interned since [`SmartString`][crate::SmartString] and thus copying /// Normal identifiers are not interned since they use `SmartString` because most identifiers in
/// is relatively fast , this just returns a copy /// Rhai are short and ASCII-based. Thus copying is relatively fast.
/// because most identifiers in Rhai are short and ASCII-based.
/// ///
/// Property getters and setters are interned separately. /// Property getters and setters are interned separately.
#[derive(Debug, Clone, Default, Hash)] #[derive(Debug, Clone, Default, Hash)]
@ -24,7 +23,7 @@ pub struct StringsInterner {
} }
impl StringsInterner { impl StringsInterner {
/// Create a new [`IdentifierBuilder`]. /// Create a new [`StringsInterner`].
#[inline] #[inline]
#[must_use] #[must_use]
pub fn new() -> Self { pub fn new() -> Self {