Quantcast
Viewing latest article 2
Browse Latest Browse All 5

Consuming, borrowing and type inference

ok, fooling around with it more, this does compile:

func consumingMap<A>(
    _ f: @escaping (inout A) -> Void
) -> (consuming Ref<A>) -> Ref<A> {
    { (ref: consuming Ref<A>) -> Ref<A> in
        var newRef = ref
        f(&newRef.value)
        return newRef
    }
}

Seems like I should not have to spell out the full type-annotation here..

Read full topic


Viewing latest article 2
Browse Latest Browse All 5

Trending Articles