Skip to content

Architecture enum vs RawRep struct #3

@mredig

Description

@mredig

How would you feel about refactoring Architecture (and I'm sure some others) into structs conforming to RawRepresentable?

proposal:

public struct Architecture: RawRepresentable, Codable, ExpressibleByStringLiteral, ExpressibleByStringInterpolation {
    public static let ppc64: Architecture = "ppc64"
    public static let ppc64le: Architecture = "ppc64le"
    public static let x86: Architecture = "386"
    public static let x86_64: Architecture = "x86_64"
    public static let amd64: Architecture = "amd64"
    public static let arm: Architecture = "arm"
    public static let arm64: Architecture = "arm64"
    public static let wasm: Architecture = "wasm"
    public static let loong64: Architecture = "loong64"
    public static let mips: Architecture = "mips"
    public static let mipsle: Architecture = "mipsle"
    public static let mips64: Architecture = "mips64"
    public static let mips64le: Architecture = "mips64le"
    public static let riscv64: Architecture = "riscv64"
    public static let s390x: Architecture = "s390x"

    public var rawValue: String

    public init(rawValue: String) {
        self.rawValue = rawValue
    }

    public init(stringLiteral value: String) {
        self.init(rawValue: value)
    }
}

This would seamlessly allow for future or overlooked architectures without requiring an update. I'm not aware of any requirement for exhaustive iteration of all architectures as would be more proper for an enum. Am I missing anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions