Skip to content

Commit

Permalink
Refine Synchronized interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkenso committed Jun 10, 2024
1 parent e3dc4cc commit b2e5a9f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension Synchronized {
read { $0 }
}

public func read<R>(_ keyPath: KeyPath<Value, R>) -> R {
public func read<R>(at keyPath: KeyPath<Value, R>) -> R {
read { $0[keyPath: keyPath] }
}

Expand Down Expand Up @@ -112,12 +112,12 @@ extension Synchronized {
self.init(primitive, nil)
}

public func initialize<T>(_ initialize: @autoclosure () -> T) -> T where Value == T? {
write {
public func initialize<T>(_ initialize: @autoclosure () throws -> T) rethrows -> T where Value == T? {
try write {
if let value = $0 {
return value
} else {
let newValue = initialize()
let newValue = try initialize()
$0 = newValue
return newValue
}
Expand Down

0 comments on commit b2e5a9f

Please sign in to comment.