Skip to content

Add GetUtf8Name and upgrade v1.0.3#4

Merged
prozolic merged 3 commits intomainfrom
v1.0.3
Mar 20, 2025
Merged

Add GetUtf8Name and upgrade v1.0.3#4
prozolic merged 3 commits intomainfrom
v1.0.3

Conversation

@prozolic
Copy link
Owner

This PR adds GetUtf8Name method that returns the enum definition name in UTF8 bytes (ReadOnlySpan<byte>).

public abstract record IpAddr
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ReadOnlySpan<byte> GetUtf8Name(IpAddr ipaddr)
    {
        return ipaddr switch
        {
            V4 => "V4"u8,
            V6 => "V6"u8,
            None => "None"u8,
            _ => []
        };
    }
}

@prozolic prozolic merged commit bd3bd4e into main Mar 20, 2025
1 check passed
@prozolic prozolic deleted the v1.0.3 branch March 20, 2025 08:08
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

Successfully merging this pull request may close these issues.

1 participant