Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't pass embed functions directly to AnyCasePath.init #3167

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum IdentifiedAction<ID: Hashable, Action>: CasePathable {
public struct AllCasePaths {
public var element: AnyCasePath<IdentifiedAction, (id: ID, action: Action)> {
AnyCasePath(
embed: IdentifiedAction.element,
embed: { .element(id: $0, action: $1) },
extract: {
guard case let .element(id, action) = $0 else { return nil }
return (id, action)
Expand Down Expand Up @@ -169,8 +169,8 @@ extension Reducer {
parent: self,
toElementsState: toElementsState,
toElementAction: .init(
embed: toElementAction.embed,
extract: toElementAction.extract
embed: { toElementAction.embed($0) },
extract: { toElementAction.extract(from: $0) }
),
element: element(),
fileID: fileID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ extension PresentationAction: CasePathable {

public var presented: AnyCasePath<PresentationAction, Action> {
AnyCasePath(
embed: PresentationAction.presented,
embed: { .presented($0) },
extract: {
guard case let .presented(value) = $0 else { return nil }
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public enum StackAction<State, Action>: CasePathable {
public struct AllCasePaths {
public var element: AnyCasePath<StackAction, (id: StackElementID, action: Action)> {
AnyCasePath(
embed: StackAction.element,
embed: { .element(id: $0, action: $1) },
extract: {
guard case let .element(id, action) = $0 else { return nil }
return (id: id, action: action)
Expand All @@ -252,7 +252,7 @@ public enum StackAction<State, Action>: CasePathable {

public var popFrom: AnyCasePath<StackAction, StackElementID> {
AnyCasePath(
embed: StackAction.popFrom,
embed: { .popFrom(id: $0) },
extract: {
guard case let .popFrom(id) = $0 else { return nil }
return id
Expand All @@ -262,7 +262,7 @@ public enum StackAction<State, Action>: CasePathable {

public var push: AnyCasePath<StackAction, (id: StackElementID, state: State)> {
AnyCasePath(
embed: StackAction.push,
embed: { .push(id: $0, state: $1) },
extract: {
guard case let .push(id, state) = $0 else { return nil }
return (id: id, state: state)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableArchitecture/SwiftUI/Binding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public protocol BindableAction {

extension BindableAction {
public var binding: BindingAction<State>? {
AnyCasePath(unsafe: Self.binding).extract(from: self)
AnyCasePath(unsafe: { .binding($0) }).extract(from: self)
}
}

Expand Down