Skip to content

Commit

Permalink
enum TireSize: RawRepresentableのrawValueの型をIntにした
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrium committed Jul 9, 2022
1 parent 29dc730 commit 201ad62
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Komusou/Settings/TireSettingView.swift
Expand Up @@ -106,17 +106,15 @@ struct TireSettingView_Previews: PreviewProvider {
enum TireSize: RawRepresentable {
static let significantDigits = 4

init?(rawValue: String) {
guard let d = Int(rawValue) else { return nil }

if let standardTireSize = StandardTireSize(rawValue: d) {
init?(rawValue: Int) {
if let standardTireSize = StandardTireSize(rawValue: rawValue) {
self = .standard(standardTireSize)
} else {
self = .custom(d)
self = .custom(rawValue)
}
}

var rawValue: String { "\(circumference)" }
var rawValue: Int { circumference }

case standard(StandardTireSize)
case custom(Int)
Expand Down

0 comments on commit 201ad62

Please sign in to comment.