View LateInitialized.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct LateInitialized<T> { | |
var storage: T? = nil | |
var wrappedValue: T { | |
get { | |
guard let value = storage else { | |
fatalError("value has not been set!") | |
} | |
return value |
View ClampedString.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct ClampedString { | |
let max: Int | |
var value: String | |
init(wrappedValue: String, max: Int) { | |
value = wrappedValue | |
self.max = max | |
} |