Use type alias for error.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
use crate::plugin::*;
|
||||
use crate::{
|
||||
def_package, Blob, Dynamic, EvalAltResult, ExclusiveRange, InclusiveRange, NativeCallContext,
|
||||
Position, RhaiResultOf, INT,
|
||||
def_package, Blob, Dynamic, ExclusiveRange, InclusiveRange, NativeCallContext, Position,
|
||||
RhaiResultOf, ERR, INT,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@@ -46,11 +46,7 @@ pub mod blob_functions {
|
||||
// Check if blob will be over max size limit
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if _ctx.engine().max_array_size() > 0 && len > _ctx.engine().max_array_size() {
|
||||
return Err(EvalAltResult::ErrorDataTooLarge(
|
||||
"Size of BLOB".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(ERR::ErrorDataTooLarge("Size of BLOB".to_string(), Position::NONE).into());
|
||||
}
|
||||
|
||||
let mut blob = Blob::new();
|
||||
@@ -121,11 +117,7 @@ pub mod blob_functions {
|
||||
// Check if blob will be over max size limit
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if _ctx.engine().max_array_size() > 0 && (len as usize) > _ctx.engine().max_array_size() {
|
||||
return Err(EvalAltResult::ErrorDataTooLarge(
|
||||
"Size of BLOB".to_string(),
|
||||
Position::NONE,
|
||||
)
|
||||
.into());
|
||||
return Err(ERR::ErrorDataTooLarge("Size of BLOB".to_string(), Position::NONE).into());
|
||||
}
|
||||
|
||||
if len as usize > blob.len() {
|
||||
@@ -205,7 +197,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
blob.extend(replace);
|
||||
return;
|
||||
@@ -244,7 +236,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return Blob::new();
|
||||
} else {
|
||||
@@ -308,7 +300,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return Blob::new();
|
||||
} else {
|
||||
@@ -344,7 +336,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return mem::take(blob);
|
||||
} else {
|
||||
@@ -373,7 +365,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return 0;
|
||||
} else {
|
||||
@@ -442,7 +434,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return;
|
||||
} else {
|
||||
@@ -511,7 +503,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return 0.0;
|
||||
} else {
|
||||
@@ -587,7 +579,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return;
|
||||
} else {
|
||||
@@ -659,7 +651,7 @@ pub mod blob_functions {
|
||||
let start = if start < 0 {
|
||||
start
|
||||
.checked_abs()
|
||||
.map_or(0, |n| blob_len - (n as usize).min(blob_len))
|
||||
.map_or(0, |n| blob_len - usize::min(n as usize, blob_len))
|
||||
} else if start as usize >= blob_len {
|
||||
return;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user