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(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<Identifier>,

View File

@ -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<INT>;
pub type InclusiveRange = std::ops::RangeInclusive<INT>;
/// An exclusive integer range.
type ExclusiveRange = std::ops::Range<INT>;
/// An inclusive integer range.
type InclusiveRange = std::ops::RangeInclusive<INT>;
pub use api::custom_syntax::Expression;
pub use ast::{FnAccess, AST};
@ -192,8 +195,11 @@ pub type Array = Vec<Dynamic>;
#[cfg(not(feature = "no_index"))]
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`.
///
/// [`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<Identifier, Dynamic>;

View File

@ -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(

View File

@ -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(|_| {

View File

@ -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 {