[swift-evolution] protocol-oriented integers (take 2)
Ben Rimmington
me at benrimmington.com
Tue Jan 17 11:43:01 CST 2017
<https://gist.github.com/moiseev/62ffe3c91b66866fdebf6f3fcc7cad8c>
public protocol Arithmetic {
init?<T : BinaryInteger>(exactly source: T)
}
public protocol BinaryInteger : Arithmetic {
init?<T : FloatingPoint>(exactly source: T)
}
Should the `init?(exactly:)` initializers belong to the same protocol?
Would this allow generic conversions between integer and floating-point types?
For example, a failable `numericCast` function.
-- Ben
More information about the swift-evolution
mailing list