AK: Make HashMap::get(Key) return an Optional<Value>.

This allows HashMap::get() to be used for value types that cannot be default
constructed (e.g NonnullOwnPtr.)
This commit is contained in:
Andreas Kling 2019-07-24 10:25:43 +02:00
commit 1d0b464618
Notes: sideshowbarker 2024-07-19 13:04:18 +09:00
10 changed files with 27 additions and 17 deletions

View file

@ -184,7 +184,8 @@ int main(int argc, char** argv)
font_menu->add_action(GAction::create(font_name, [&terminal, &config](const GAction& action) {
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
config->write_entry("Text", "Font", metadata.path);
ASSERT(metadata.has_value());
config->write_entry("Text", "Font", metadata.value().path);
config->sync();
terminal.force_repaint();
}));