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

Architecture enum vs RawRep struct #3

Open
mredig opened this issue Nov 20, 2024 · 1 comment
Open

Architecture enum vs RawRep struct #3

mredig opened this issue Nov 20, 2024 · 1 comment

Comments

@mredig
Copy link

mredig commented Nov 20, 2024

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?

@mredig
Copy link
Author

mredig commented Nov 20, 2024

(I bring this up because x86_64 was overlooked until I added it in my fork)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant