using System.Collections; using System.Collections.Generic; namespace ZeroLevel.Services.Async.Internal { /// Turns out iterating through manually boxed iterator is a bit faster than through automatically boxed one. internal class BoxedEnumerator : IEnumerator where TEnumerator : struct, IEnumerator { private TEnumerator _structEnumerator; public BoxedEnumerator(TEnumerator structEnumerator) { _structEnumerator = structEnumerator; } public TItem Current => _structEnumerator.Current; object IEnumerator.Current => Current; public void Dispose() => _structEnumerator.Dispose(); public bool MoveNext() => _structEnumerator.MoveNext(); public void Reset() => _structEnumerator.Reset(); } }