public void TemporaryBuffer_Apply() { using var buffer = new TemporaryBuffer <int>(1) { 100, 200, 300 }; Func <int[], int, int> sumf = (data, pos) => data.AsSpan().Slice(0, pos).ToArray().Sum(); int sum = buffer.Apply(sumf); Assert.Equal(600, sum); sum = 0; buffer.Apply((data, pos) => sum = sumf(data, pos)); Assert.Equal(600, sum); }
// extracts text from inside the link [[<target>|<text>]] or [[<text>]] private State processLink(char ch) { switch (ch) { case ']' when buffer.Last() == ']': buffer.Apply(actionCommitLink); buffer.Discard(); return(State.NormalText); default: buffer.Add(ch); return(State.Link); } }