Skip to content

Instantly share code, notes, and snippets.

View mattmassicotte's full-sized avatar

Matt Massicotte mattmassicotte

View GitHub Profile
import SwiftUI
import AsyncAlgorithms
struct AsyncChanges<V>: ViewModifier where V : Equatable, V: Sendable {
typealias Element = (oldValue: V, newValue: V)
typealias Action = (AsyncStream<Element>) async -> Void
@State private var streamPair = AsyncStream<Element>.makeStream()
private let action: Action
private let value: V

Set value

GCC_PREPROCESSOR_DEFINITIONS = FOO=My Value

Add Constants.m

It is particularly important to check that the definition of your value exists here, as it will not cause a compilation failure, but instead result in the generation of @"FOO".

@import Foundation;
import Foundation
extension NotificationCenter {
public func addOIsolatedObserver<Payload>(
forName name: Notification.Name,
object obj: Any? = nil,
isolation: (any Actor)? = #isolation,
process: @Sendable @escaping (Notification) -> Payload,
using block: @Sendable @escaping (Payload) -> Void
) -> any NSObjectProtocol where Payload : Sendable {
---Constraint solving at [/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:1 - line:6:25]---
(overload set choice binding $T2 := (StaticString, StaticString...) -> ())
---Initial constraints for the given expression---
(macro_expansion_expr type="()" location=/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:1 range=[/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:1 - line:6:25] name="IndexKeyRecord" discriminator=0
(argument_list
(argument
(string_literal_expr type="$T0" location=/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:17 range=[/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:17 - line:6:17] encoding=utf8 value="a" builtin_initializer="**NULL**" initializer="**NULL**"))
(argument
(string_literal_expr type="$T1" location=/Users/matt/Developer/Empire/Tests/EmpireTests/IndexKeyRecordTests.swift:6:22 range=[/Users/matt/Developer/Empire/Tests/EmpireTe
class NonSendable {
var value = 1
}
class NonIsolated {
private var mutableState = NonSendable()
func aFunc() async {
mutableState.value += 1
}
import Foundation
struct TimeoutError: Error {
}
extension AsyncThrowingStream.Continuation where Failure == Error {
func timeoutTask(with interval: TimeInterval) -> Task<Void, Error> {
let sleepNS = UInt64(interval * 1_000_000_000)
return Task {
import AsyncAlgorithms
enum Event<Element: Sendable> {
case element(Element)
case timeout
}
struct TimeoutAsyncSequence<Base, C: Clock>: AsyncSequence where Base : AsyncSequence, Base.Element : Sendable, Base: Sendable {
let base: Base
let interval: C.Instant.Duration