<PackageReference Include="System.Reactive" Version="6.0.2" />

Scan<TSource>

sealed class Scan<TSource> : Producer<TSource, _<TSource>>
using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 1 })] internal sealed class Scan<[System.Runtime.CompilerServices.Nullable(2)] TSource> : Producer<TSource, Scan<TSource>._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : IdentitySink<TSource> { private readonly Func<TSource, TSource, TSource> _accumulator; [System.Runtime.CompilerServices.Nullable(2)] private TSource _accumulation; private bool _hasAccumulation; public _(Func<TSource, TSource, TSource> accumulator, IObserver<TSource> observer) : base(observer) { _accumulator = accumulator; } public override void OnNext(TSource value) { try { if (_hasAccumulation) _accumulation = _accumulator(_accumulation, value); else { _accumulation = value; _hasAccumulation = true; } } catch (Exception error) { ForwardOnError(error); return; } ForwardOnNext(_accumulation); } } private readonly IObservable<TSource> _source; private readonly Func<TSource, TSource, TSource> _accumulator; public Scan(IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator) { _source = source; _accumulator = accumulator; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] protected override _ CreateSink(IObserver<TSource> observer) { return new _(_accumulator, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0 })] _ sink) { sink.Run(_source); } } }