Skip to content

Commit

Permalink
Fix Equatable and Hashable conformances
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Jan 16, 2023
1 parent d88929e commit 8207c5b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Sources/ToastUI/ToastState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CasePaths
import SwiftUI
import SwiftUINavigation

public struct ToastState: Identifiable, Equatable, Hashable {
public struct ToastState: Identifiable {
public let id = UUID()

let style: ToastView.Style
Expand All @@ -24,6 +24,24 @@ public struct ToastState: Identifiable, Equatable, Hashable {
}
}

extension ToastState: Equatable {
public static func == (lhs: ToastState, rhs: ToastState) -> Bool {
lhs.style == rhs.style &&
lhs.icon == rhs.icon &&
lhs.title == rhs.title &&
lhs.subtitle == rhs.subtitle
}
}

extension ToastState: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(style)
hasher.combine(icon)
hasher.combine(title)
hasher.combine(subtitle)
}
}

extension View {
public func toast(
unwrapping value: Binding<ToastState?>,
Expand Down

0 comments on commit 8207c5b

Please sign in to comment.