use std::collections::BTreeMap;
use std::ascii::AsciiExt;

pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
    input
        .iter()
        .flat_map(|(k, v)| v.iter().map(move |x| (x.to_ascii_lowercase(), *k)))
        .collect()
}

use std::collections::BTreeMap;
use std::ascii::AsciiExt;

pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
    let mut result: BTreeMap<char, i32> = BTreeMap::new();

    for (k, v) in input {
        for c in v {
            result.entry((*c).to_ascii_lowercase()).or_insert(*k);
        }
    }

    result
}

--- 
+++ 
@@ -2,13 +2,8 @@
 use std::ascii::AsciiExt;
 
 pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
-    let mut result: BTreeMap<char, i32> = BTreeMap::new();
-
-    for (k, v) in input {
-        for c in v {
-            result.entry((*c).to_ascii_lowercase()).or_insert(*k);
-        }
-    }
-
-    result
+    input
+        .iter()
+        .flat_map(|(k, v)| v.iter().map(move |x| (x.to_ascii_lowercase(), *k)))
+        .collect()
 }
Change rust code for etl

I like this functional programming style
