class_name InspectIterator extends Iterator

var iterator: Iterator
var fn: Callable

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

func next() -> Option:
    match iterator.next():
        var x when x.is_some():
            fn.call(x.unwrap())
            return x
        var x: return x
