Use immutable strings.

This commit is contained in:
Stephen Chung
2020-05-25 13:44:28 +08:00
parent bbed4c6ef4
commit 99ea2b33c9
14 changed files with 251 additions and 191 deletions

View File

@@ -1,8 +1,6 @@
use crate::def_package;
use crate::module::FuncReturn;
use crate::parser::INT;
use crate::stdlib::string::String;
use crate::parser::{ImmutableString, INT};
// Comparison operators
pub fn lt<T: PartialOrd>(x: T, y: T) -> FuncReturn<bool> {
@@ -50,12 +48,12 @@ def_package!(crate:LogicPackage:"Logical operators.", lib, {
// reg_op!(lib, "!=", ne, INT, char, bool, ());
// Special versions for strings - at least avoid copying the first string
// lib.set_fn_2_mut("<", |x: &mut String, y: String| Ok(*x < y));
// lib.set_fn_2_mut("<=", |x: &mut String, y: String| Ok(*x <= y));
// lib.set_fn_2_mut(">", |x: &mut String, y: String| Ok(*x > y));
// lib.set_fn_2_mut(">=", |x: &mut String, y: String| Ok(*x >= y));
// lib.set_fn_2_mut("==", |x: &mut String, y: String| Ok(*x == y));
// lib.set_fn_2_mut("!=", |x: &mut String, y: String| Ok(*x != y));
// lib.set_fn_2("<", |x: ImmutableString, y: ImmutableString| Ok(*x < y));
// lib.set_fn_2("<=", |x: ImmutableString, y: ImmutableString| Ok(*x <= y));
// lib.set_fn_2(">", |x: ImmutableString, y: ImmutableString| Ok(*x > y));
// lib.set_fn_2(">=", |x: ImmutableString, y: ImmutableString| Ok(*x >= y));
// lib.set_fn_2("==", |x: ImmutableString, y: ImmutableString| Ok(*x == y));
// lib.set_fn_2("!=", |x: ImmutableString, y: ImmutableString| Ok(*x != y));
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]