Simplify dc_array_get_string

This commit is contained in:
Alexander Krotov
2019-07-23 00:09:10 +03:00
parent a323fe68a6
commit 85dfd65e48

View File

@@ -285,16 +285,17 @@ pub unsafe fn dc_array_get_string(
let cnt = (*array).array.len(); let cnt = (*array).array.len();
let sep = as_str(sep); let sep = as_str(sep);
let res = (*array).array.iter().enumerate().fold( let res =
String::with_capacity(2 * cnt), (*array)
|mut res, (i, n)| { .array
.iter()
.enumerate()
.fold(String::with_capacity(2 * cnt), |res, (i, n)| {
if i == 0 { if i == 0 {
res += &n.to_string(); res + &n.to_string()
} else { } else {
res += sep; res + sep + &n.to_string()
res += &n.to_string();
} }
res
}); });
to_cstring(res) to_cstring(res)
} }