From 85dfd65e48bdb9b7990e2bf83f94684738d26771 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 23 Jul 2019 00:09:10 +0300 Subject: [PATCH] Simplify dc_array_get_string --- src/dc_array.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dc_array.rs b/src/dc_array.rs index 2a5d240fc..a9a8b6967 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -285,17 +285,18 @@ pub unsafe fn dc_array_get_string( let cnt = (*array).array.len(); let sep = as_str(sep); - let res = (*array).array.iter().enumerate().fold( - String::with_capacity(2 * cnt), - |mut res, (i, n)| { - if i == 0 { - res += &n.to_string(); - } else { - res += sep; - res += &n.to_string(); - } - res - }); + let res = + (*array) + .array + .iter() + .enumerate() + .fold(String::with_capacity(2 * cnt), |res, (i, n)| { + if i == 0 { + res + &n.to_string() + } else { + res + sep + &n.to_string() + } + }); to_cstring(res) }