I tried copying your code snippet into the playground but it fails to compile due to a bunch of missing variables and functions. There was also a syntax error because you've got a trailing }).collect(), but I'm guessing that was an accident from when you copy/pasted the code into your post.
fn main() {
let row = "this is a string";
row.chars()
.enumerate()
.map(|(col, c)| match c {
CRCT => CRCT,
_ => count_char(col_index, row_index, charfield),
})
.inspect(|col_index| println!("col_index {}", &col_index))
.inspect(|c| println!("c {}", &c))
.collect::<String>();
}
Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find function `count_char` in this scope
--> src/main.rs:8:18
|
8 | _ => count_char(col_index, row_index, charfield),
| ^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `col_index` in this scope
--> src/main.rs:8:29
|
8 | _ => count_char(col_index, row_index, charfield),
| ^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `row_index` in this scope
--> src/main.rs:8:40
|
8 | _ => count_char(col_index, row_index, charfield),
| ^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `charfield` in this scope
--> src/main.rs:8:51
|
8 | _ => count_char(col_index, row_index, charfield),
| ^^^^^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0425`.
error: could not compile `playground` due to 4 previous errors
Something that often helps people with reproducing your issue is if you can write up a minimal example on the playground. That way we have all the code and can hit the "build" button to see any compile errors you are having.