Это C# по ссылке 🤣
ну ты ведь знаешь что C# это та же джава, так что смысл тот же. Например в твоем коде:
subset.iter().for_each(|rec| {
wtr.serialize(rec);
});
Тебе компилятор показывает что ты не обрабатываешь ошибку (который ты игнорируешь в своем коде, к слову). Если написать так:
subset.iter().for_each(|rec| {
wtr.serialize(rec)?;
});
То нифига не заработает, потому что форыч не возвращает ошибку. А вот так:
for rec in subset.iter() {
writer.serialize(rec)?;
}
Всё отлично работает.
Поэтому вот это утверждение:
The second reason is that doing so adds zero new representational power to the language. Doing this lets you rewrite this perfectly clear code:
foreach(Foo foo in foos){ statement involving foo; }
into this code:
foos.ForEach((Foo foo)=>{ statement involving foo; });
which uses almost exactly the same characters in slightly different order. And yet the second version is harder to understand, harder to debug, and introduces closure semantics, thereby potentially changing object lifetimes in subtle ways.
Отлично относится и к шарпу, и к джаве, и к скале, и особенно к расту (где вместо эксепшнов резалты)