1
- use cirru_edn:: Edn ;
1
+ use cirru_edn:: { Edn , EdnListView } ;
2
2
use regex:: Regex ;
3
3
4
4
#[ no_mangle]
5
5
pub fn abi_version ( ) -> String {
6
- String :: from ( "0.0.6 " )
6
+ String :: from ( "0.0.7 " )
7
7
}
8
8
9
9
#[ no_mangle]
@@ -51,8 +51,8 @@ pub fn re_find(args: Vec<Edn>) -> Result<Edn, String> {
51
51
Ok ( p) => {
52
52
let mut matched = p. find_iter ( s) ;
53
53
match matched. next ( ) {
54
- Some ( v) => Ok ( Edn :: Str ( v. as_str ( ) . to_string ( ) . into_boxed_str ( ) ) ) ,
55
- None => Ok ( Edn :: Str ( "" . to_owned ( ) . into_boxed_str ( ) ) ) , // TODO maybe nil
54
+ Some ( v) => Ok ( Edn :: Str ( v. as_str ( ) . to_string ( ) . into ( ) ) ) ,
55
+ None => Ok ( Edn :: Str ( "" . to_owned ( ) . into ( ) ) ) , // TODO maybe nil
56
56
}
57
57
}
58
58
Err ( e) => Err ( format ! ( "re-find failed, {}" , e) ) ,
@@ -73,9 +73,9 @@ pub fn re_find_all(args: Vec<Edn>) -> Result<Edn, String> {
73
73
Ok ( p) => {
74
74
let mut ys: Vec < Edn > = vec ! [ ] ;
75
75
for v in p. find_iter ( s) {
76
- ys. push ( Edn :: Str ( v. as_str ( ) . to_string ( ) . into_boxed_str ( ) ) )
76
+ ys. push ( Edn :: Str ( v. as_str ( ) . to_string ( ) . into ( ) ) )
77
77
}
78
- Ok ( Edn :: List ( ys ) )
78
+ Ok ( Edn :: List ( EdnListView ( ys ) ) )
79
79
}
80
80
Err ( e) => Err ( format ! ( "re-find-all failed, {}" , e) ) ,
81
81
} ,
@@ -96,7 +96,7 @@ pub fn re_split(args: Vec<Edn>) -> Result<Edn, String> {
96
96
for piece in p. split ( s) {
97
97
ys. push ( Edn :: str ( piece) ) ;
98
98
}
99
- Ok ( Edn :: List ( ys ) )
99
+ Ok ( Edn :: List ( EdnListView ( ys ) ) )
100
100
}
101
101
Err ( e) => Err ( format ! ( "re-split failed, {}" , e) ) ,
102
102
} ,
@@ -112,13 +112,10 @@ pub fn re_replace_all(args: Vec<Edn>) -> Result<Edn, String> {
112
112
if args. len ( ) == 3 {
113
113
match ( & args[ 0 ] , & args[ 1 ] , & args[ 2 ] ) {
114
114
( Edn :: Str ( s) , Edn :: Str ( pattern) , Edn :: Str ( next) ) => match Regex :: new ( pattern) {
115
- Ok ( p) => Ok ( Edn :: str ( p. replace_all ( & * * s, & * * next) . into_owned ( ) ) ) ,
115
+ Ok ( p) => Ok ( Edn :: str ( p. replace_all ( s, & * * next) . into_owned ( ) ) ) ,
116
116
Err ( e) => Err ( format ! ( "re-replace-all failed, {}" , e) ) ,
117
117
} ,
118
- ( a, b, c) => Err ( format ! (
119
- "re-replace-all expected 3 strings: {} {} {}" ,
120
- a, b, c
121
- ) ) ,
118
+ ( a, b, c) => Err ( format ! ( "re-replace-all expected 3 strings: {} {} {}" , a, b, c) ) ,
122
119
}
123
120
} else {
124
121
Err ( format ! ( "re-replace-all expected 3 strings: {:?}" , args) )
0 commit comments