You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift 5.9 (SE-0377) introduces borrowing and consuming parameter ownership modifiers.
An immediate use case
I'm working on some utility methods with the following inout convention:
@inlinablepublicstaticfunc incrementSufficientUnsignedInteger<T>(
_ pointee:inoutT, by digit:T.Element, plus bit:inoutBool, at index:inoutT.Index)where T:MutableCollection, T.Element:NBKFixedWidthInteger&NBKUnsignedInteger{...}
These are used instead of the much more ergonomic return convention:
@inlinablepublicstaticfunc incrementSufficientUnsignedInteger<T>(
_ pointee:inoutT, by digit:T.Element, plus bit:Bool, at index:T.Index)->(index:T.Index, overflow:Bool)where T:MutableCollection, T.Element:NBKFixedWidthInteger&NBKUnsignedInteger{...}
I've tried every reasonable combination of attributes, but can't make it perform as well as the inout version. I assume this is related to parameter ownership, and that I want to consume the arguments. I'm not sure this is the solution, but I hope so:
@inlinablepublicstaticfunc incrementSufficientUnsignedInteger<T>(
_ pointee:inoutT, by digit:consumingT.Element, plus bit:consumingBool, at index:consumingT.Index)->(index:T.Index, overflow:Bool)where T:MutableCollection, T.Element:NBKFixedWidthInteger&NBKUnsignedInteger{...}
The text was updated successfully, but these errors were encountered:
Hm. I'm not convinced it's a solution to the problem mentioned, but there are still other uses for it. More so with UIntXL (#33), where it is important to avoid unnecessary copy-on-writes.
Introduction
Swift 5.9 (SE-0377) introduces
borrowing
andconsuming
parameter ownership modifiers.An immediate use case
I'm working on some utility methods with the following
inout
convention:These are used instead of the much more ergonomic
return
convention:I've tried every reasonable combination of attributes, but can't make it perform as well as the
inout
version. I assume this is related to parameter ownership, and that I want toconsume
the arguments. I'm not sure this is the solution, but I hope so:The text was updated successfully, but these errors were encountered: