LinqLinker.cs

/*
    LinqLinker .NET struct & static class
    Copyright (C) 2026 Joshua 'Joan Metek(illot)' Kidder

    This module is free software: you can redistribute it and/or modify
    it under the terms of the GNU Less General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This module is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this module. If not, see <https://www.gnu.org/licenses/>.
*/

using System.Collections;
using System.Collections.Generic;
using System.Reflection.Metadata.Ecma335;
using Microsoft.VisualBasic;

namespace System.Linq
{

    public static class LinqLinker
    {
        public static LinqLinker<TChainedLink> Link<TChainedLink>(IEnumerable<TChainedLink> _toLinq)
        {
            return new LinqLinker<TChainedLink>(_toLinq);
        }
    }
    public readonly partial struct LinqLinker<TChainedLink> : IEnumerable<TChainedLink>
    {
        private readonly IEnumerable<TChainedLink> _wrapped;
        public static LinqLinker<TChainedLink> Link(IEnumerable<TChainedLink> toLinq)
        {
            return new LinqLinker<TChainedLink>(toLinq);
        }
        public IEnumerable<TChainedLink> Unlink()
        {
            return _wrapped;
        }
        public LinqLinker(IEnumerable<TChainedLink> __wrapped)
        {
            _wrapped = __wrapped;
        }

        public override string? ToString() => _wrapped.ToString();


        public IEnumerator<TChainedLink> GetEnumerator()
        {
            return _wrapped.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}