use map_while to count for always err case.

Reasons:
- Filter_map will run forever if iterator only returns Err with lines.
  This is a possibility for "lines" iterators.
- Map_while will break the mapping the moment the iterator returns error.

Signed-off-by: Perma Alesheikh <me@prma.dev>
This commit is contained in:
Perma Alesheikh 2024-01-09 14:18:09 +03:30 committed by Clément DOUIN
parent b417ad11a0
commit 2af1936ef8
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
4 changed files with 4 additions and 4 deletions

View file

@ -88,7 +88,7 @@ impl MessageSaveCommand {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.map_while(Result::ok)
.collect::<Vec<String>>()
.join("\r\n")
};

View file

@ -110,7 +110,7 @@ impl MessageSendCommand {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.map_while(Result::ok)
.collect::<Vec<_>>()
.join("\r\n")
};

View file

@ -92,7 +92,7 @@ impl TemplateSaveCommand {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.map_while(Result::ok)
.collect::<Vec<String>>()
.join("\n")
};

View file

@ -113,7 +113,7 @@ impl TemplateSendCommand {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.map_while(Result::ok)
.collect::<Vec<_>>()
.join("\n")
};