Remove redundant std.

This commit is contained in:
Stephen Chung 2021-04-20 19:19:35 +08:00
parent 0f66c67f82
commit 8ff1f57900
9 changed files with 18 additions and 27 deletions

View File

@ -68,7 +68,7 @@ pub struct ScriptFnDef {
/// Function doc-comments (if any).
#[cfg(not(feature = "no_function"))]
#[cfg(feature = "metadata")]
pub comments: StaticVec<std::string::String>,
pub comments: StaticVec<String>,
}
impl fmt::Display for ScriptFnDef {

View File

@ -1717,13 +1717,13 @@ impl From<&ImmutableString> for Dynamic {
impl From<&crate::Identifier> for Dynamic {
#[inline(always)]
fn from(value: &crate::Identifier) -> Self {
std::string::ToString::to_string(value).into()
value.to_string().into()
}
}
#[cfg(not(feature = "no_index"))]
impl<T: Variant + Clone> From<std::vec::Vec<T>> for Dynamic {
impl<T: Variant + Clone> From<Vec<T>> for Dynamic {
#[inline(always)]
fn from(value: std::vec::Vec<T>) -> Self {
fn from(value: Vec<T>) -> Self {
Self(Union::Array(
Box::new(value.into_iter().map(Dynamic::from).collect()),
AccessMode::ReadWrite,

View File

@ -59,7 +59,7 @@ impl Engine {
#[cfg(feature = "metadata")]
let mut param_type_names: crate::StaticVec<_> = F::param_names()
.iter()
.map(|ty| std::format!("_: {}", self.map_type_name(ty)))
.map(|ty| format!("_: {}", self.map_type_name(ty)))
.collect();
#[cfg(feature = "metadata")]
@ -119,7 +119,7 @@ impl Engine {
#[cfg(feature = "metadata")]
let param_type_names: crate::StaticVec<_> = F::param_names()
.iter()
.map(|ty| std::format!("_: {}", self.map_type_name(ty)))
.map(|ty| format!("_: {}", self.map_type_name(ty)))
.chain(std::iter::once(
self.map_type_name(F::return_type_name()).into(),
))
@ -1172,7 +1172,7 @@ impl Engine {
let mut f = std::fs::File::open(path.clone()).map_err(|err| {
EvalAltResult::ErrorSystem(
std::format!("Cannot open script file '{}'", path.to_string_lossy()),
format!("Cannot open script file '{}'", path.to_string_lossy()),
err.into(),
)
})?;
@ -1181,7 +1181,7 @@ impl Engine {
f.read_to_string(&mut contents).map_err(|err| {
EvalAltResult::ErrorSystem(
std::format!("Cannot read script file '{}'", path.to_string_lossy()),
format!("Cannot read script file '{}'", path.to_string_lossy()),
err.into(),
)
})?;
@ -2010,16 +2010,13 @@ impl Engine {
/// 2) Functions in registered sub-modules
/// 3) Functions in packages (optional)
#[cfg(feature = "metadata")]
pub fn gen_fn_signatures(&self, include_packages: bool) -> std::vec::Vec<String> {
let mut signatures: std::vec::Vec<_> = Default::default();
pub fn gen_fn_signatures(&self, include_packages: bool) -> Vec<String> {
let mut signatures: Vec<_> = Default::default();
signatures.extend(self.global_namespace.gen_fn_signatures());
self.global_sub_modules.iter().for_each(|(name, m)| {
signatures.extend(
m.gen_fn_signatures()
.map(|f| std::format!("{}::{}", name, f)),
)
signatures.extend(m.gen_fn_signatures().map(|f| format!("{}::{}", name, f)))
});
if include_packages {

View File

@ -5,7 +5,6 @@
use crate::dynamic::Variant;
use crate::{Dynamic, StaticVec};
use std::vec::Vec;
/// Trait that parses arguments to a function call.
///

View File

@ -463,7 +463,7 @@ impl Engine {
) -> RhaiResult {
#[inline(always)]
fn make_error(
name: std::string::String,
name: String,
fn_def: &crate::ast::ScriptFnDef,
state: &State,
err: Box<EvalAltResult>,

View File

@ -72,7 +72,7 @@ impl FuncInfo {
let mut sig = format!("{}(", self.name);
if !self.param_names.is_empty() {
let mut params: std::vec::Vec<String> =
let mut params: Vec<String> =
self.param_names.iter().map(|s| s.as_str().into()).collect();
let return_type = params.pop().unwrap_or_else(|| "()".into());
sig.push_str(&params.join(", "));
@ -200,7 +200,7 @@ impl fmt::Debug for Module {
&self
.functions
.values()
.map(|f| std::string::ToString::to_string(&f.func))
.map(|f| f.func.to_string())
.collect::<BTreeSet<_>>(),
);
}

View File

@ -4,9 +4,6 @@ use std::ops::Range;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[cfg(not(feature = "unchecked"))]
use std::string::ToString;
#[cfg(not(feature = "unchecked"))]
use num_traits::{CheckedAdd as Add, CheckedSub as Sub};
@ -209,8 +206,6 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
pub fn new(from: Decimal, to: Decimal, step: Decimal) -> Result<Self, Box<EvalAltResult>> {
#[cfg(not(feature = "unchecked"))]
if step.is_zero() {
use std::string::ToString;
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
Box::new(EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE)),
crate::Position::NONE,

View File

@ -103,7 +103,7 @@ mod print_debug_functions {
)]
pub fn format_array(ctx: NativeCallContext, array: &mut Array) -> ImmutableString {
let len = array.len();
let mut result = std::string::String::with_capacity(len * 5 + 2);
let mut result = String::with_capacity(len * 5 + 2);
result.push_str("[");
array.iter_mut().enumerate().for_each(|(i, x)| {
@ -130,7 +130,7 @@ mod print_debug_functions {
)]
pub fn format_map(ctx: NativeCallContext, map: &mut Map) -> ImmutableString {
let len = map.len();
let mut result = std::string::String::with_capacity(len * 5 + 3);
let mut result = String::with_capacity(len * 5 + 3);
result.push_str("#{");
map.iter_mut().enumerate().for_each(|(i, (k, v))| {

View File

@ -2516,7 +2516,7 @@ fn parse_stmt(
#[cfg(not(feature = "no_function"))]
#[cfg(feature = "metadata")]
let comments = {
let mut comments: StaticVec<std::string::String> = Default::default();
let mut comments: StaticVec<String> = Default::default();
let mut comments_pos = Position::NONE;
// Handle doc-comments.
@ -2771,7 +2771,7 @@ fn parse_fn(
mut settings: ParseSettings,
#[cfg(not(feature = "no_function"))]
#[cfg(feature = "metadata")]
comments: StaticVec<std::string::String>,
comments: StaticVec<String>,
) -> Result<ScriptFnDef, ParseError> {
#[cfg(not(feature = "unchecked"))]
settings.ensure_level_within_max_limit(state.max_expr_depth)?;