Use a more idiomatic way to convert a HashMap to an Option<HashMap>

This commit is contained in:
Sofía Aritz 2023-03-11 20:51:25 +01:00
parent c92e73328d
commit 482f3f7fb0

View file

@ -235,16 +235,11 @@ impl eframe::App for App {
ui.add_space(10.0);
if ui.button("add note").clicked() {
// FIXME(sofia@git.sofiaritz.com): Use a more idiomatic way
let metadata = if let Some(metadata) = self.metadata_buffer.clone() {
if metadata.is_empty() {
None
} else {
Some(metadata)
}
} else {
None
};
let metadata = self.metadata_buffer.clone()
.and_then(|metadata| {
(!metadata.is_empty())
.then_some(metadata)
});
let note = Note::Decrypted {
id: SystemTime::now()