Revert "Refine examples."

This reverts commit 146129279c.
This commit is contained in:
Stephen Chung
2022-01-16 22:50:39 +08:00
parent 146129279c
commit 5935a88958
6 changed files with 43 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
//! Type to hold a mutable reference to the target of an evaluation.
use crate::types::dynamic::Variant;
use crate::{Dynamic, RhaiResultOf};
use crate::{Dynamic, RhaiResultOf, INT};
use std::ops::{Deref, DerefMut};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
@@ -11,9 +11,8 @@ use std::prelude::v1::*;
// Negative starting positions count from the end.
//
// Values going over bounds are limited to the actual length.
#[inline]
#[allow(dead_code)]
pub fn calc_offset_len(length: usize, start: crate::INT, len: crate::INT) -> (usize, usize) {
#[inline(always)]
pub fn calc_offset_len(length: usize, start: INT, len: INT) -> (usize, usize) {
let start = if start < 0 {
start.checked_abs().map_or(0, |positive_start| {
length - usize::min(positive_start as usize, length)
@@ -40,11 +39,10 @@ pub fn calc_offset_len(length: usize, start: crate::INT, len: crate::INT) -> (us
// Negative starting positions count from the end.
//
// Values going over bounds call the provided closure to return a default value or an error.
#[inline]
#[allow(dead_code)]
#[inline(always)]
pub fn calc_index<E>(
length: usize,
start: crate::INT,
start: INT,
negative_count_from_end: bool,
err: impl Fn() -> Result<usize, E>,
) -> Result<usize, E> {