Consuming, borrowing and type inference
The following fails to compile: struct Ref<T>: ~Copyable { var value: T init(_ value: T) { self.value = value } } func consumingMap<A>( _ f: @escaping (inout A) -> Void ) ->...
View ArticleConsuming, 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...
View ArticleConsuming, borrowing and type inference
I think ‘consuming’ ought to be inferred here from the return type (similarly if it were bound to a variable with that explicit type annotation). I’m not sure if that inference was part of the...
View ArticleConsuming, borrowing and type inference
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...
View ArticleConsuming, borrowing and type inference
Yes, a function should always be able to mutate its own parameter if that parameter is consuming. Read full topic
View Article