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
to implement this with current implementations would mean that Data would have to have overloads for every single number of tuple element counts (which I would imagine would be expensive in terms of binary size).
So imagine a protocol as such:
protocol HomogenousTuple {
associatedtype Element
}
so a tuple as such:
(UInt8, UInt8, UInt8)
would adopt by compiler emission the protocol HomogenousTuple with the associated type Element as UInt8
This means that Data could adopt it as such:
extension Data {
public init<Tuple: HomogenousTuple>(bytes: Tuple) where Tuple.Element == UInt8 {
...
}
}
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 8a8c9b3d5187913c99e7f1d321f78f13
relates to:
Issue Description:
In many cases it would be more efficient to initialize a Data with a tuple of values. However there is no way to generically implement this.
e.g.
Data(bytes: (0x0f, 0x01))
Data(bytes: (0x0f, 0x01, 0x02))
to implement this with current implementations would mean that Data would have to have overloads for every single number of tuple element counts (which I would imagine would be expensive in terms of binary size).
So imagine a protocol as such:
protocol HomogenousTuple {
associatedtype Element
}
so a tuple as such:
(UInt8, UInt8, UInt8)
would adopt by compiler emission the protocol HomogenousTuple with the associated type Element as UInt8
This means that Data could adopt it as such:
extension Data {
public init<Tuple: HomogenousTuple>(bytes: Tuple) where Tuple.Element == UInt8 {
...
}
}
The text was updated successfully, but these errors were encountered: