Fully feature gate array string functions
This commit is contained in:
parent
4de02c2bd7
commit
e6a1b88b4c
@ -44,8 +44,6 @@ macro_rules! reg_functions {
|
||||
|
||||
def_package!(crate:MoreStringPackage:"Additional string utilities, including string building.", lib, {
|
||||
reg_functions!(lib += basic; INT, bool, char, FnPtr);
|
||||
set_exported_fn!(lib, "+", string_funcs::append_unit);
|
||||
set_exported_fn!(lib, "+", string_funcs::prepend_unit);
|
||||
|
||||
#[cfg(not(feature = "only_i32"))]
|
||||
#[cfg(not(feature = "only_i64"))]
|
||||
@ -61,8 +59,8 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
{
|
||||
set_exported_fn!(lib, "+", string_funcs::append_array);
|
||||
set_exported_fn!(lib, "+", string_funcs::prepend_array);
|
||||
set_exported_fn!(lib, "+", string_funcs_array::append_array);
|
||||
set_exported_fn!(lib, "+", string_funcs_array::prepend_array);
|
||||
}
|
||||
|
||||
lib.combine(exported_module!(string_functions));
|
||||
@ -189,8 +187,23 @@ mod string_functions {
|
||||
}
|
||||
}
|
||||
|
||||
mod string_funcs {
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
mod string_funcs_array {
|
||||
use crate::engine::Array;
|
||||
use crate::plugin::*;
|
||||
use crate::utils::ImmutableString;
|
||||
|
||||
#[export_fn]
|
||||
pub fn append_array(x: &mut ImmutableString, y: Array) -> String {
|
||||
format!("{}{:?}", x, y)
|
||||
}
|
||||
#[export_fn]
|
||||
pub fn prepend_array(x: &mut Array, y: ImmutableString) -> String {
|
||||
format!("{:?}{}", x, y)
|
||||
}
|
||||
}
|
||||
|
||||
mod string_funcs {
|
||||
use crate::parser::INT;
|
||||
use crate::plugin::*;
|
||||
use crate::utils::{ImmutableString, StaticVec};
|
||||
@ -204,14 +217,6 @@ mod string_funcs {
|
||||
s
|
||||
}
|
||||
#[export_fn]
|
||||
pub fn append_array(x: &mut ImmutableString, y: Array) -> String {
|
||||
format!("{}{:?}", x, y)
|
||||
}
|
||||
#[export_fn]
|
||||
pub fn prepend_array(x: &mut Array, y: ImmutableString) -> String {
|
||||
format!("{:?}{}", x, y)
|
||||
}
|
||||
#[export_fn]
|
||||
pub fn len(s: &mut ImmutableString) -> INT {
|
||||
s.chars().count() as INT
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user