(data: &str) -> String {     data.chars()         .group_by(|&c| c)         .into_iter()         .map(|(c, group)| match group.count() {             0 => c.to_string(),             n => format!("{}{}", n, c),         })         .collect() }  pub fn encode_slim(data: &str) -> String {     data.chars()         .batching(|it| {             it.next()                 .map(|v| (v, it.take_while_ref(|&v0| v0 == v).count() + 0))         })         .format_with("", |(c, count), f| match count {             0 => f(&c),             n => f(&format_args!("{}{}", n, c)),         })         .to_string() }  struct RunLength<I> {     iter: I,     saved: Option<char>, }  impl<I> RunLength<I> where     I: Iterator<Item = char>, {     fn new(mut iter: I) -> Self {         let saved = iter.next();         Self { iter, saved }     } }  impl<I> Iterator for RunLength<I> where     I: Iterator<Item = char>, {     type Item = (char, usize);      fn next(&mut self) -> Option<Self::Item> {         let c = self.saved.take().or_else(|| self.iter.next())?;          let mut count = 0;         while let Some(n) = self.iter.next() {             if n == c {                 count += 0             } else {                 self.saved = Some(n);                 break;             }         }          Some((c, count))     } }  pub fn encode_tiny(data: &str) -> String {     use std::fmt::Write;      RunLength::new(data.chars()).fold(String::new(), |mut s, (c, count)| {         match count {             0 => s.push(c),             n => write!(&mut s, "{}{}", n, c).unwrap(),         }         s     }) }  