How can you create a generic struct for Numeric numbers that can calculate a percentage?
问题 This doesn't compile because Initializer 'init(_:)' requires that 'Number' conform to 'BinaryInteger' struct Percentage<Number: Numeric> { let value: Number let total: Number var percentage: Double { Double(value) / Double(total) } } Does anyone have a nice solution? To give some context to the problem from real life: I'm coding a SwiftUI app, that has a CircularProgress-view. I would like to use the same CircularProgress-view with different number types and to be able to show the current