Skip to content

[Im]PerfectRadixUIntRoot #68

@oscbyspro

Description

@oscbyspro

I have some awkward signatures, backed by some awkward assertions. Look at these two:

func _encodeBigEndianTextWhereRadixIsUIntRoot(_ value: inout ANKSigned<Self>, radix: RadixUIntRoot, uppercase: Bool) -> String {
    assert(radix.power.isZero)
    ...
}

func _encodeBigEndianTextWhereRadixIsNotUIntRoot(_ value: inout ANKSigned<Self>, radix: RadixUIntRoot, uppercase: Bool) -> String {
    assert(!radix.power.isZero)
    ...
}

But wouldn't a compile-time check be neat? With two new wrapper types, I can reduce it to:

func _encodeBigEndianText(_ value: inout ANKSigned<Self>, radix: RadixUIntRoot.Perfect, uppercase: Bool) -> String {
    ...
}

func _encodeBigEndianText(_ value: inout ANKSigned<Self>, radix: RadixUIntRoot.Imperfect, uppercase: Bool) -> String {
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    brrrsuch code, much wow

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions