Merge pull request #137 from kkebo/refactor-with-switch-expressions

This commit is contained in:
Kenta Kubo 2025-09-05 04:32:55 +09:00 committed by GitHub
commit 47c4f34d32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 22 deletions

View file

@ -10,16 +10,11 @@ import NetworkExtension
extension NEOnDemandRuleAction: @retroactive CustomStringConvertible {
public var description: String {
switch self {
case .connect:
return "Apply settings"
case .disconnect:
return "Do not apply settings"
case .evaluateConnection:
return "Apply with excluded domains"
case .ignore:
return "As is"
default:
return "Unknown"
case .connect: "Apply settings"
case .disconnect: "Do not apply settings"
case .evaluateConnection: "Apply with excluded domains"
case .ignore: "As is"
@unknown case _: "Unknown"
}
}
}

View file

@ -10,9 +10,9 @@ import NetworkExtension
extension NEOnDemandRuleInterfaceType: @retroactive CaseIterable {
public static var allCases: [Self] {
#if os(macOS)
return [.any, .ethernet, .wiFi]
[.any, .ethernet, .wiFi]
#else
return [.any, .wiFi, .cellular]
[.any, .wiFi, .cellular]
#endif
}
}

View file

@ -10,20 +10,15 @@ import NetworkExtension
extension NEOnDemandRuleInterfaceType: @retroactive CustomStringConvertible {
public var description: String {
switch self {
case .any:
return "Any"
case .any: "Any"
#if os(macOS)
case .ethernet:
return "Ethernet"
case .ethernet: "Ethernet"
#endif
case .wiFi:
return "Wi-Fi"
case .wiFi: "Wi-Fi"
#if os(iOS)
case .cellular:
return "Cellular"
case .cellular: "Cellular"
#endif
default:
return "Unknown"
@unknown case _: "Unknown"
}
}
}