2022-07-27 10:57:16 +01:00
|
|
|
//
|
2024-09-06 16:34:30 +03:00
|
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
2022-07-27 10:57:16 +01:00
|
|
|
//
|
2025-01-06 11:27:37 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2022-07-27 10:57:16 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2023-04-14 14:24:48 +02:00
|
|
|
@propertyWrapper struct Consumable<Value> {
|
|
|
|
var wrappedValue: Value? {
|
|
|
|
mutating get {
|
|
|
|
defer {
|
|
|
|
value = nil
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
value = newValue
|
|
|
|
}
|
2022-11-21 19:37:13 +03:00
|
|
|
}
|
|
|
|
|
2023-04-14 14:24:48 +02:00
|
|
|
private var value: Value?
|
2022-11-21 19:37:13 +03:00
|
|
|
|
2023-04-14 14:24:48 +02:00
|
|
|
init(value: Value? = nil) {
|
|
|
|
self.value = value
|
2022-07-27 10:57:16 +01:00
|
|
|
}
|
|
|
|
}
|