diff --git a/Sources/OpenSwiftUI/Data/Environment/EnvironmentKey.swift b/Sources/OpenSwiftUI/Data/Environment/EnvironmentKey.swift deleted file mode 100644 index d229b020..00000000 --- a/Sources/OpenSwiftUI/Data/Environment/EnvironmentKey.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// EnvironmentKey.swift -// OpenSwiftUI -// -// Audited for RELEASE_2021 -// Status: Complete - -public protocol EnvironmentKey { - associatedtype Value - - @inline(__always) - static var defaultValue: Value { get } -} diff --git a/Sources/OpenSwiftUICore/Data/Environment/EnvironmentKey.swift b/Sources/OpenSwiftUICore/Data/Environment/EnvironmentKey.swift new file mode 100644 index 00000000..6d15d11f --- /dev/null +++ b/Sources/OpenSwiftUICore/Data/Environment/EnvironmentKey.swift @@ -0,0 +1,32 @@ +// +// EnvironmentKey.swift +// OpenSwiftUICore +// +// Audited for RELEASE_2024 +// Status: Complete + +internal import OpenGraphShims + +public protocol EnvironmentKey { + associatedtype Value + + static var defaultValue: Value { get } + + #if OPENSWIFTUI_SUPPORT_2022_API + static func _valuesEqual(_ lhs: Self.Value, _ rhs: Self.Value) -> Bool + #endif +} + +#if OPENSWIFTUI_SUPPORT_2022_API +extension EnvironmentKey { + public static func _valuesEqual(_ lhs: Self.Value, _ rhs: Self.Value) -> Bool { + compareValues(lhs, rhs) + } +} + +extension EnvironmentKey where Value: Equatable { + public static func _valuesEqual(_ lhs: Self.Value, _ rhs: Self.Value) -> Bool { + lhs == rhs + } +} +#endif diff --git a/Sources/OpenSwiftUICore/Util/OptionSet+Extension.swift b/Sources/OpenSwiftUICore/Util/OptionSet+Extension.swift new file mode 100644 index 00000000..8199d760 --- /dev/null +++ b/Sources/OpenSwiftUICore/Util/OptionSet+Extension.swift @@ -0,0 +1,17 @@ +// +// OptionSet+Extension.swift +// OpenSwiftUICore +// +// Audited for RELEASE_2024 +// Status: Complete + +extension OptionSet { + @inlinable + package mutating func setValue(_ value: Bool, for set: Self) { + if value { + formUnion(set) + } else { + subtract(set) + } + } +}