1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibKeyboard: Change some Optional<T> returns to ErrorOr<T>

Makes CharacterMapFile::load_from_file and CharacterMap::load_from_file
return ErrorOr instead of Optional. This makes them a little nicer to
use and a little easier to read, as they seem to have been approximating
this.
This commit is contained in:
RasmusNylander 2021-12-16 17:46:49 +01:00 committed by Andreas Kling
parent 017135b44e
commit 4e65c4dae4
5 changed files with 10 additions and 22 deletions

View file

@ -17,13 +17,11 @@ namespace Keyboard {
#ifndef KERNEL
// The Kernel explicitly and exclusively links only this file into it.
// Thus, we cannot even include a reference to the symbol `CharacterMapFile::load_from_file`.
Optional<CharacterMap> CharacterMap::load_from_file(const String& map_name)
ErrorOr<CharacterMap> CharacterMap::load_from_file(const String& map_name)
{
auto result = CharacterMapFile::load_from_file(map_name);
if (!result.has_value())
return {};
auto result = TRY(CharacterMapFile::load_from_file(map_name));
return CharacterMap(map_name, result.value());
return CharacterMap(map_name, result);
}
#endif