Merge pull request #501 from martindevans/LLamaPos_inc_dec

Added increment and decrement operators to `LLamaPos`
This commit is contained in:
Martin Evans 2024-02-07 19:02:57 +00:00 committed by GitHub
commit 859160d6f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -35,4 +35,24 @@ public record struct LLamaPos
/// <param name="value"></param>
/// <returns></returns>
public static implicit operator LLamaPos(int value) => new(value);
/// <summary>
/// Increment this position
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public static LLamaPos operator ++(LLamaPos pos)
{
return new LLamaPos(pos.Value + 1);
}
/// <summary>
/// Increment this position
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public static LLamaPos operator --(LLamaPos pos)
{
return new LLamaPos(pos.Value - 1);
}
}