fn and_then_or_clear<T, U>(
    opt: &mut Option<T>,
    f: impl FnOnce(&mut T) -> Option<U>
) -> Option<U>