Quantcast
Channel: Consuming, borrowing and type inference
Viewing all articles
Browse latest Browse all 5

Consuming, borrowing and type inference

$
0
0

that was my thinking too, but this stuff is all so new to me that I'm never sure if I have properly understood the concept. Another quick question, should ref be mutable there? i.e. should I be able to say:

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

Intuitively I would think I could or at least that it would be desirable. At present trying it that way yields:

error: couldn't IRGen expression. Please enable the expression log by running "log enable lldb expr", then run the failing expression again, and file a bug report with the log output.

I've reported that as a compiler bug, but my I can't tell if (when the compiler gets fixed) that should work or not.

Read full topic


Viewing all articles
Browse latest Browse all 5

Trending Articles