mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
Simplify dc_array_get_string
This commit is contained in:
@@ -285,17 +285,18 @@ 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
|
||||||
if i == 0 {
|
.iter()
|
||||||
res += &n.to_string();
|
.enumerate()
|
||||||
} else {
|
.fold(String::with_capacity(2 * cnt), |res, (i, n)| {
|
||||||
res += sep;
|
if i == 0 {
|
||||||
res += &n.to_string();
|
res + &n.to_string()
|
||||||
}
|
} else {
|
||||||
res
|
res + sep + &n.to_string()
|
||||||
});
|
}
|
||||||
|
});
|
||||||
to_cstring(res)
|
to_cstring(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user