class_name MapIterator extends Iterator

var iterator: Iterator
var morphism: Callable

func _init(iterator: Iterator, fn: Callable) -> void:
    self.iterator = iterator
    self.morphism = fn

func next() -> Option:
    match iterator.next():
        var x when x.is_some():
            return Option.some(morphism.call(x.unwrap()))
        _: return Option.none
