From 100 Days of SwiftUI
To demonstrate property wrappers, I want to start with a simple struct that wraps some kind of BinaryInteger value. We’re going to give this thing some custom code when it comes to setting its wrapped value, so that if the new value is below 0 we instead make it exactly 0 so that this struct can never be negative.
Our code would look like this:
struct NonNegative<Value: BinaryInteger> {
var value: Value