mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: implement suggestions
This commit is contained in:
@@ -24,6 +24,21 @@ sealed class Option<T> {
|
||||
None() => onNone(),
|
||||
};
|
||||
|
||||
Option<U> flatMap<U>(Option<U> Function(T value) f) => switch (this) {
|
||||
Some(:final value) => f(value),
|
||||
None() => const Option.none(),
|
||||
};
|
||||
|
||||
void ifSome(void Function(T value) action) {
|
||||
switch (this) {
|
||||
case Some(:final value):
|
||||
action(value);
|
||||
break;
|
||||
case None():
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => switch (this) {
|
||||
Some(:final value) => 'Some($value)',
|
||||
|
||||
Reference in New Issue
Block a user