• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

neon-sunset / U8String / 5909906392

19 Aug 2023 06:18AM UTC coverage: 22.422% (+0.7%) from 21.682%
5909906392

push

github

neon-sunset
fix+docs: fix tests build and update TODO

120 of 772 branches covered (15.54%)

Branch coverage included in aggregate %.

50 of 50 new or added lines in 1 file covered. (100.0%)

428 of 1672 relevant lines covered (25.6%)

30558.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/U8String.Splitting.cs
1
using System.Collections;
2
using System.Runtime.InteropServices;
3
using System.Text;
4
using U8Primitives.Abstractions;
5
using U8Primitives.InteropServices;
6

7
#pragma warning disable RCS1085, RCS1085FadeOut, IDE0032 // Use auto-implemented property. Why: readable fields.
8
namespace U8Primitives;
9

10
public readonly partial struct U8String
11
{
12
    public U8SplitPair SplitFirst(byte separator)
13
    {
14
        if (!U8Info.IsAsciiByte(separator))
×
15
        {
16
            // TODO: EH UX
17
            ThrowHelpers.ArgumentOutOfRange();
×
18
        }
19

20
        var source = this;
×
21
        if (!source.IsEmpty)
×
22
        {
23
            var span = source.UnsafeSpan;
×
24
            var index = span.IndexOf(separator);
×
25
            if (index >= 0)
×
26
            {
27
                return new(source, index, 1);
×
28
            }
29

30
            return U8SplitPair.NotFound(source);
×
31
        }
32

33
        return default;
×
34
    }
35

36
    public U8SplitPair SplitFirst(char separator) => char.IsAscii(separator)
×
37
        ? SplitFirst((byte)separator)
×
38
        : SplitFirstUnchecked(separator.NonAsciiToUtf8(out _));
×
39

40
    public U8SplitPair SplitFirst(Rune separator) => separator.IsAscii
×
41
        ? SplitFirst((byte)separator.Value)
×
42
        : SplitFirstUnchecked(separator.NonAsciiToUtf8(out _));
×
43

44
    public U8SplitPair SplitFirst(U8String separator)
45
    {
46
        var source = this;
×
47
        if (!source.IsEmpty)
×
48
        {
49
            if (!separator.IsEmpty)
×
50
            {
51
                var span = source.UnsafeSpan;
×
52
                var index = span.IndexOf(separator.UnsafeSpan);
×
53
                if (index >= 0)
×
54
                {
55
                    return new(source, index, separator.Length);
×
56
                }
57
            }
58

59
            return U8SplitPair.NotFound(source);
×
60
        }
61

62
        return default;
×
63
    }
64

65
    // It would be *really nice* to aggressively inline this method
66
    // but the way validation is currently implemented does not significantly
67
    // benefit from splitting on UTF-8 literals while possibly risking
68
    // running out of inlining budget significantly regressing performance everywhere else.
69
    public U8SplitPair SplitFirst(ReadOnlySpan<byte> separator)
70
    {
71
        var source = this;
×
72
        if (!source.IsEmpty)
×
73
        {
74
            if (!separator.IsEmpty)
×
75
            {
76
                var span = source.UnsafeSpan;
×
77
                var index = span.IndexOf(separator);
×
78
                if (index >= 0)
×
79
                {
80
                    // Same as with Slice(int, int), this might dereference past the end of the string.
81
                    // TODO: Do something about it if it's ever an issue.
82
                    if (U8Info.IsContinuationByte(source.UnsafeRefAdd(index)) ||
×
83
                        U8Info.IsContinuationByte(source.UnsafeRefAdd(index + separator.Length)))
×
84
                    {
85
                        ThrowHelpers.InvalidSplit();
×
86
                    }
87

88
                    return new(source, index, separator.Length);
×
89
                }
90
            }
91

92
            return U8SplitPair.NotFound(source);
×
93
        }
94

95
        return default;
×
96
    }
97

98
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
99
    public U8SplitPair SplitFirstUnchecked(ReadOnlySpan<byte> separator)
100
    {
101
        var source = this;
×
102
        if (!source.IsEmpty)
×
103
        {
104
            if (!separator.IsEmpty)
×
105
            {
106
                var span = source.UnsafeSpan;
×
107
                var index = span.IndexOf(separator);
×
108
                if (index >= 0)
×
109
                {
110
                    return new(source, index, separator.Length);
×
111
                }
112
            }
113

114
            return U8SplitPair.NotFound(source);
×
115
        }
116

117
        return default;
×
118
    }
119

120
    public U8SplitPair SplitLast(byte separator)
121
    {
122
        if (!U8Info.IsAsciiByte(separator))
×
123
        {
124
            // TODO: EH UX
125
            ThrowHelpers.ArgumentOutOfRange();
×
126
        }
127

128
        var source = this;
×
129
        if (!source.IsEmpty)
×
130
        {
131
            var span = source.UnsafeSpan;
×
132
            var index = span.LastIndexOf(separator);
×
133
            if (index >= 0)
×
134
            {
135
                return new(source, index, 1);
×
136
            }
137

138
            return U8SplitPair.NotFound(source);
×
139
        }
140

141
        return default;
×
142
    }
143

144
    public U8SplitPair SplitLast(char separator) => char.IsAscii(separator)
×
145
        ? SplitLast((byte)separator)
×
146
        : SplitLastUnchecked(separator.NonAsciiToUtf8(out _));
×
147

148
    public U8SplitPair SplitLast(Rune separator) => separator.IsAscii
×
149
        ? SplitLast((byte)separator.Value)
×
150
        : SplitLastUnchecked(separator.NonAsciiToUtf8(out _));
×
151

152
    public U8SplitPair SplitLast(U8String separator)
153
    {
154
        var source = this;
×
155
        if (!source.IsEmpty)
×
156
        {
157
            if (!separator.IsEmpty)
×
158
            {
159
                var span = source.UnsafeSpan;
×
160
                var index = span.LastIndexOf(separator.UnsafeSpan);
×
161
                if (index >= 0)
×
162
                {
163
                    return new(source, index, separator.Length);
×
164
                }
165
            }
166

167
            return U8SplitPair.NotFound(source);
×
168
        }
169

170
        return default;
×
171
    }
172

173
    public U8SplitPair SplitLast(ReadOnlySpan<byte> separator)
174
    {
175
        var source = this;
×
176
        if (!source.IsEmpty)
×
177
        {
178
            if (!separator.IsEmpty)
×
179
            {
180
                var span = source.UnsafeSpan;
×
181
                var index = span.LastIndexOf(separator);
×
182
                if (index >= 0)
×
183
                {
184
                    if (U8Info.IsContinuationByte(source.UnsafeRefAdd(index)) ||
×
185
                        U8Info.IsContinuationByte(source.UnsafeRefAdd(index + separator.Length)))
×
186
                    {
187
                        ThrowHelpers.InvalidSplit();
×
188
                    }
189

190
                    return new(source, index, separator.Length);
×
191
                }
192
            }
193

194
            return U8SplitPair.NotFound(source);
×
195
        }
196

197
        return default;
×
198
    }
199

200
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
201
    public U8SplitPair SplitLastUnchecked(ReadOnlySpan<byte> separator)
202
    {
203
        var source = this;
×
204
        if (!source.IsEmpty)
×
205
        {
206
            if (!separator.IsEmpty)
×
207
            {
208
                var span = source.UnsafeSpan;
×
209
                var index = span.LastIndexOf(separator);
×
210
                if (index >= 0)
×
211
                {
212
                    return new(source, index, separator.Length);
×
213
                }
214
            }
215

216
            return U8SplitPair.NotFound(source);
×
217
        }
218

219
        return default;
×
220
    }
221

222
    public U8Split<byte> Split(byte separator)
223
    {
224
        if (!U8Info.IsAsciiByte(separator))
×
225
        {
226
            ThrowHelpers.ArgumentOutOfRange();
×
227
        }
228

229
        return new(this, separator);
×
230
    }
231

232
    public ConfiguredU8Split<byte> Split(byte separator, U8SplitOptions options)
233
    {
234
        if (!U8Info.IsAsciiByte(separator))
×
235
        {
236
            ThrowHelpers.ArgumentOutOfRange();
×
237
        }
238

239
        return new(this, separator, options);
×
240
    }
241

242
    public U8Split<char> Split(char separator)
243
    {
244
        if (char.IsSurrogate(separator))
×
245
        {
246
            ThrowHelpers.ArgumentOutOfRange();
×
247
        }
248

249
        return new(this, separator);
×
250
    }
251

252
    public ConfiguredU8Split<char> Split(char separator, U8SplitOptions options)
253
    {
254
        if (char.IsSurrogate(separator))
×
255
        {
256
            ThrowHelpers.ArgumentOutOfRange();
×
257
        }
258

259
        return new(this, separator, options);
×
260
    }
261

262
    public U8Split<Rune> Split(Rune separator) => new(this, separator);
×
263

264
    public ConfiguredU8Split<Rune> Split(Rune separator, U8SplitOptions options) => new(this, separator, options);
×
265

266
    public U8Split Split(U8String separator)
267
    {
268
        return !separator.IsEmpty ? new(this, separator) : default;
×
269
    }
270

271
    public ConfiguredU8Split<U8String> Split(U8String separator, U8SplitOptions options)
272
    {
273
        return !separator.IsEmpty ? new(this, separator, options) : default;
×
274
    }
275

276
    public U8Split<byte[]> Split(byte[] separator)
277
    {
278
        if (!IsValid(separator))
×
279
        {
280
            // TODO: EH UX
281
            ThrowHelpers.InvalidSplit();
×
282
        }
283

284
        var source = this;
×
285
        return (!source.IsEmpty && separator != null) ? new(source, separator) : default;
×
286
    }
287

288
    public ConfiguredU8Split<byte[]> Split(byte[] separator, U8SplitOptions options)
289
    {
290
        if (!IsValid(separator))
×
291
        {
292
            // TODO: EH UX
293
            ThrowHelpers.InvalidSplit();
×
294
        }
295

296
        var source = this;
×
297
        return (!source.IsEmpty && separator != null) ? new(source, separator, options) : default;
×
298
    }
299
}
300

301
public readonly record struct U8SplitPair
302
{
303
    readonly U8String _value;
304
    readonly int _offset;
305
    readonly int _stride;
306

307
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
308
    internal U8SplitPair(U8String value, int offset, int stride)
309
    {
310
        _value = value;
×
311
        _offset = offset;
×
312
        _stride = stride;
×
313
    }
×
314

315
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
316
    public static U8SplitPair NotFound(U8String value)
317
    {
318
        return new(value, value.Length, 0);
×
319
    }
320

321
    public U8String Segment
322
    {
323
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
324
        get => U8Marshal.Slice(_value, 0, _offset);
×
325
    }
326

327
    public U8String Remainder
328
    {
329
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
330
        get => U8Marshal.Slice(_value, _offset + _stride);
×
331
    }
332

333
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
334
    public void Deconstruct(out U8String segment, out U8String remainder)
335
    {
336
        segment = Segment;
×
337
        remainder = Remainder;
×
338
    }
×
339

340
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
341
    public static implicit operator (U8String, U8String)(U8SplitPair value)
342
    {
343
        return (value.Segment, value.Remainder);
×
344
    }
345
}
346

347
public struct U8Split : ICollection<U8String>, IU8Enumerable<U8Split.Enumerator>
348
{
349
    readonly U8String _value;
350
    readonly U8String _separator;
351
    int _count;
352

353
    internal U8Split(U8String value, U8String separator)
354
    {
355
        if (!value.IsEmpty)
×
356
        {
357
            _value = value;
×
358
            _separator = separator;
×
359
            _count = -1;
×
360
        }
361
    }
×
362

363
    public int Count
364
    {
365
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
366
        get
367
        {
368
            var count = _count;
×
369
            if (count >= 0)
×
370
            {
371
                return count;
×
372
            }
373

374
            // Matches the behavior of string.Split('\n').Length for "hello\n"
375
            // TODO: Should we break consistency and not count the very last segment if it is empty?
376
            return _count = Count(_value.UnsafeSpan, _separator) + 1;
×
377

378
            static int Count(ReadOnlySpan<byte> value, ReadOnlySpan<byte> separator)
379
            {
380
                return U8Searching.Count(value, separator);
×
381
            }
382
        }
383
    }
384

385
    public readonly bool Contains(U8String item)
386
    {
387
        var separator = _separator;
×
388
        var overlaps = item.Contains(separator);
×
389

390
        return !overlaps && _value.Contains(item);
×
391
    }
392

393
    public void CopyTo(U8String[] array, int index)
394
    {
395
        this.CopyTo<U8Split, Enumerator>(array.AsSpan()[index..]);
×
396
    }
×
397

398
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
399
    public readonly void Deconstruct(out U8String first, out U8String second)
400
    {
401
        this.Deconstruct<U8Split, Enumerator>(out first, out second);
×
402
    }
×
403

404
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
405
    public readonly void Deconstruct(out U8String first, out U8String second, out U8String third)
406
    {
407
        this.Deconstruct<U8Split, Enumerator>(out first, out second, out third);
×
408
    }
×
409

410
    public U8String[] ToArray() => this.ToArray<U8Split, Enumerator>();
×
411
    public List<U8String> ToList() => this.ToList<U8Split, Enumerator>();
×
412

413
    /// <summary>
414
    /// Returns a <see cref="Enumerator"/> over the provided string.
415
    /// </summary>
416
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
417
    public readonly Enumerator GetEnumerator() => new(_value, _separator);
×
418

419
    readonly IEnumerator<U8String> IEnumerable<U8String>.GetEnumerator() => GetEnumerator();
×
420
    readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
×
421
    readonly bool ICollection<U8String>.IsReadOnly => true;
×
422

423
    [StructLayout(LayoutKind.Auto)]
424
    public struct Enumerator : IU8Enumerator
425
    {
426
        readonly byte[]? _value;
427
        readonly U8String _separator;
428
        U8Range _current;
429
        U8Range _remaining;
430

431
        internal Enumerator(U8String value, U8String separator)
432
        {
433
            _value = value._value;
×
434
            _separator = separator;
×
435
            _remaining = value._inner;
×
436
        }
×
437

438
        public readonly U8String Current => new(_value, _current.Offset, _current.Length);
×
439

440
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
441
        public bool MoveNext()
442
        {
443
            var remaining = _remaining;
×
444
            if (remaining.Length > 0)
×
445
            {
446
                var value = _value!.SliceUnsafe(remaining.Offset, remaining.Length);
×
447
                var separator = _separator;
×
448
                var index = value.IndexOf(separator.UnsafeSpan);
×
449
                if (index >= 0)
×
450
                {
451
                    _current = new(remaining.Offset, index);
×
452
                    _remaining = new(
×
453
                        remaining.Offset + index + separator.Length,
×
454
                        remaining.Length - index - separator.Length);
×
455
                }
456
                else
457
                {
458
                    _current = remaining;
×
459
                    _remaining = default;
×
460
                }
461

462
                return true;
×
463
            }
464

465
            return false;
×
466
        }
467

468
        readonly object IEnumerator.Current => Current;
×
469
        readonly void IEnumerator.Reset() => throw new NotSupportedException();
×
470
        readonly void IDisposable.Dispose() { }
×
471
    }
472

473
    readonly void ICollection<U8String>.Add(U8String item) => throw new NotSupportedException();
×
474
    readonly void ICollection<U8String>.Clear() => throw new NotSupportedException();
×
475
    readonly bool ICollection<U8String>.Remove(U8String item) => throw new NotSupportedException();
×
476
}
477

478
// TODO: I don't think this is a successful design. JIT/ILC can't optimize away
479
// ASCII char literal conversion causing the size of MoveNext() to explode. This needs an overhaul,
480
// possibly disambiguating on struct vs separator types or maybe even 3 options:
481
// primitive, span (ref split aka SplitRef? SplitSpan?) and U8String / byte[]
482
[StructLayout(LayoutKind.Auto)]
483
public struct U8Split<TSeparator> :
484
    ICollection<U8String>,
485
    IU8Enumerable<U8Split<TSeparator>.Enumerator>
486
{
487
    readonly U8String _value;
488
    readonly TSeparator? _separator;
489
    int _count;
490

491
    // TODO: Move value.IsEmpty -> count = 0 check here
492
    internal U8Split(U8String value, TSeparator? separator)
493
    {
494
        _value = value;
×
495
        _separator = separator;
×
496
        _count = value.IsEmpty ? 0 : -1;
×
497
    }
×
498

499
    public int Count
500
    {
501
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
502
        get
503
        {
504
            var count = _count;
×
505
            if (count >= 0)
×
506
            {
507
                return count;
×
508
            }
509

510
            // Matches the behavior of string.Split('\n').Length for "hello\n"
511
            // TODO: Should we break consistency and not count the very last segment if it is empty?
512
            return _count = Count(_value, _separator) + 1;
×
513

514
            static int Count(ReadOnlySpan<byte> value, TSeparator? separator)
515
            {
516
                return U8Searching.Count(value, separator);
×
517
            }
518
        }
519
    }
520

521
    public readonly bool Contains(U8String item)
522
    {
523
        var separator = _separator;
×
524
        var overlaps = U8Searching.Contains(item, separator);
×
525

526
        return !overlaps && _value.Contains(item);
×
527
    }
528

529
    public void CopyTo(U8String[] array, int index)
530
    {
531
        this.CopyTo<U8Split<TSeparator>, Enumerator>(array.AsSpan()[index..]);
×
532
    }
×
533

534
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
535
    public readonly void Deconstruct(out U8String first, out U8String second)
536
    {
537
        this.Deconstruct<U8Split<TSeparator>, Enumerator>(out first, out second);
×
538
    }
×
539

540
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
541
    public readonly void Deconstruct(out U8String first, out U8String second, out U8String third)
542
    {
543
        this.Deconstruct<U8Split<TSeparator>, Enumerator>(out first, out second, out third);
×
544
    }
×
545

546
    public U8String[] ToArray() => this.ToArray<U8Split<TSeparator>, Enumerator>();
×
547
    public List<U8String> ToList() => this.ToList<U8Split<TSeparator>, Enumerator>();
×
548

549
    /// <summary>
550
    /// Returns a <see cref="Enumerator"/> over the provided string.
551
    /// </summary>
552
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
553
    public readonly Enumerator GetEnumerator() => new(_value, _separator);
×
554

555
    readonly IEnumerator<U8String> IEnumerable<U8String>.GetEnumerator() => GetEnumerator();
×
556
    readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
×
557
    readonly bool ICollection<U8String>.IsReadOnly => true;
×
558

559
    [StructLayout(LayoutKind.Auto)]
560
    public struct Enumerator : IU8Enumerator
561
    {
562
        readonly byte[]? _value;
563
        readonly TSeparator? _separator;
564
        readonly U8Size _separatorSize;
565
        U8Range _current;
566
        U8Range _remaining;
567

568
        internal Enumerator(U8String value, TSeparator? separator)
569
        {
570
            _value = value._value;
×
571
            _separator = separator;
×
572
            _separatorSize = U8Info.GetSize(separator);
×
573
            _remaining = value._inner;
×
574
        }
×
575

576
        public readonly U8String Current => new(_value, _current.Offset, _current.Length);
×
577

578
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
579
        public bool MoveNext()
580
        {
581
            var remaining = _remaining;
×
582
            if (remaining.Length > 0)
×
583
            {
584
                var size = _separatorSize;
×
585
                var value = _value!.SliceUnsafe(remaining.Offset, remaining.Length);
×
586
                var index = U8Searching.IndexOf(value, _separator, size);
×
587
                if (index >= 0)
×
588
                {
589
                    _current = new(remaining.Offset, index);
×
590
                    _remaining = new(
×
591
                        remaining.Offset + index + (int)size,
×
592
                        remaining.Length - index - (int)size);
×
593
                }
594
                else
595
                {
596
                    _current = remaining;
×
597
                    _remaining = default;
×
598
                }
599

600
                return true;
×
601
            }
602

603
            return false;
×
604
        }
605

606
        readonly object IEnumerator.Current => Current;
×
607
        readonly void IEnumerator.Reset() => throw new NotSupportedException();
×
608
        readonly void IDisposable.Dispose() { }
×
609
    }
610

611
    readonly void ICollection<U8String>.Add(U8String item) => throw new NotSupportedException();
×
612
    readonly void ICollection<U8String>.Clear() => throw new NotSupportedException();
×
613
    readonly bool ICollection<U8String>.Remove(U8String item) => throw new NotSupportedException();
×
614
}
615

616
public readonly struct ConfiguredU8Split<TSeparator> :
617
    IU8Enumerable<ConfiguredU8Split<TSeparator>.Enumerator>
618
{
619
    readonly U8String _value;
620
    readonly TSeparator? _separator;
621
    readonly U8SplitOptions _options;
622

623
    internal ConfiguredU8Split(U8String value, TSeparator? separator, U8SplitOptions options)
624
    {
625
        _value = value;
×
626
        _separator = separator;
×
627
        _options = options;
×
628
    }
×
629

630
    public readonly Enumerator GetEnumerator() => new(_value, _separator, _options);
×
631

632
    readonly IEnumerator<U8String> IEnumerable<U8String>.GetEnumerator() => GetEnumerator();
×
633
    readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
×
634

635
    public struct Enumerator : IU8Enumerator
636
    {
637
        readonly byte[]? _value;
638
        readonly TSeparator? _separator;
639
        readonly U8Size _separatorSize;
640
        readonly U8SplitOptions _options;
641
        U8Range _current;
642
        U8Range _remaining;
643

644
        internal Enumerator(U8String value, TSeparator? separator, U8SplitOptions options)
645
        {
646
            _value = value._value;
×
647
            _separator = separator;
×
648
            _separatorSize = U8Info.GetSize(separator);
×
649
            _options = options;
×
650
            _remaining = value._inner;
×
651
        }
×
652

653
        public readonly U8String Current => new(_value, _current.Offset, _current.Length);
×
654

655
        // TODO: Not most efficient but it works for now
656
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
657
        public bool MoveNext()
658
        {
659
        Next:
660
            var remaining = _remaining;
×
661
            if (remaining.Length > 0)
×
662
            {
663
                var size = _separatorSize;
×
664
                var value = _value!.SliceUnsafe(remaining.Offset, remaining.Length);
×
665
                var index = U8Searching.IndexOf(value, _separator, size);
×
666
                if (index >= 0)
×
667
                {
668
                    _current = (_options & U8SplitOptions.Trim) != U8SplitOptions.Trim
×
669
                        ? new(remaining.Offset, index)
×
670
                        : TrimEntry(_value!, new(remaining.Offset, index));
×
671
                    _remaining = new(
×
672
                        remaining.Offset + index + (int)size,
×
673
                        remaining.Length - index - (int)size);
×
674
                }
675
                else
676
                {
677
                    _current = (_options & U8SplitOptions.Trim) != U8SplitOptions.Trim
×
678
                        ? remaining
×
679
                        : TrimEntry(_value!, remaining);
×
680
                    _remaining = default;
×
681
                }
682

683
                if ((_options & U8SplitOptions.RemoveEmpty) is U8SplitOptions.RemoveEmpty
×
684
                    && _current.Length is 0)
×
685
                {
686
                    goto Next;
687
                }
688

689
                return true;
×
690
            }
691

692
            return false;
×
693
        }
694

695
        private static U8Range TrimEntry(byte[] value, U8Range range)
696
        {
697
            // This could have been done better but works for now.
698
            return new U8String(value, range).Trim()._inner;
×
699
        }
700

701
        readonly object IEnumerator.Current => Current;
×
702
        readonly void IEnumerator.Reset() => throw new NotSupportedException();
×
703
        readonly void IDisposable.Dispose() { }
×
704
    }
705
}
706

707
// // TODO:
708
// public ref struct U8RefSplit
709
// {
710
//     readonly U8String _value;
711
//     readonly ReadOnlySpan<byte> _separator;
712
//     // Can't force JIT/ILC to emit proper layout here which is sad, and explicit layout ruins codegen
713
//     // int _count;
714
// }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc