mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
#nullable disable
|
|
namespace NadekoBot.Common;
|
|
|
|
public struct ShmartNumber : IEquatable<ShmartNumber>
|
|
{
|
|
public long Value { get; }
|
|
public string Input { get; }
|
|
|
|
public ShmartNumber(long val, string input = null)
|
|
{
|
|
Value = val;
|
|
Input = input;
|
|
}
|
|
|
|
public static implicit operator ShmartNumber(long num)
|
|
=> new(num);
|
|
|
|
public static implicit operator long(ShmartNumber num)
|
|
=> num.Value;
|
|
|
|
public static implicit operator ShmartNumber(int num)
|
|
=> new(num);
|
|
|
|
public override string ToString()
|
|
=> Value.ToString();
|
|
|
|
public override bool Equals(object obj)
|
|
=> obj is ShmartNumber sn && Equals(sn);
|
|
|
|
public bool Equals(ShmartNumber other)
|
|
=> other.Value == Value;
|
|
|
|
public override int GetHashCode()
|
|
=> Value.GetHashCode() ^ Input.GetHashCode(StringComparison.InvariantCulture);
|
|
|
|
public static bool operator ==(ShmartNumber left, ShmartNumber right)
|
|
=> left.Equals(right);
|
|
|
|
public static bool operator !=(ShmartNumber left, ShmartNumber right)
|
|
=> !(left == right);
|
|
} |