• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / U8String / 5872750434

pending completion
5872750434

push

github

neon-sunset
feat: U8SplitOptions.Trim impl. on Split

105 of 742 branches covered (14.15%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

372 of 1600 relevant lines covered (23.25%)

444.8 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
        if (!value.IsEmpty)
×
495
        {
496
            _value = value;
×
497
            _separator = separator;
×
498
            _count = -1;
×
499
        }
500
    }
×
501

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

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

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

524
    public readonly bool Contains(U8String item)
525
    {
526
        var separator = _separator;
×
527
        var overlaps = U8Searching.Contains(item, separator);
×
528

529
        return !overlaps && _value.Contains(item);
×
530
    }
531

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

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

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

549
    public U8String[] ToArray() => this.ToArray<U8Split<TSeparator>, Enumerator>();
×
550
    public List<U8String> ToList() => this.ToList<U8Split<TSeparator>, Enumerator>();
×
551

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

558
    readonly IEnumerator<U8String> IEnumerable<U8String>.GetEnumerator() => GetEnumerator();
×
559
    readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
×
560
    readonly bool ICollection<U8String>.IsReadOnly => true;
×
561

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

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

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

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

603
                return true;
×
604
            }
605

606
            return false;
×
607
        }
608

609
        readonly object IEnumerator.Current => Current;
×
610
        readonly void IEnumerator.Reset() => throw new NotSupportedException();
×
611
        readonly void IDisposable.Dispose() { }
×
612
    }
613

614
    readonly void ICollection<U8String>.Add(U8String item) => throw new NotSupportedException();
×
615
    readonly void ICollection<U8String>.Clear() => throw new NotSupportedException();
×
616
    readonly bool ICollection<U8String>.Remove(U8String item) => throw new NotSupportedException();
×
617
}
618

619
public readonly struct ConfiguredU8Split<TSeparator> :
620
    IU8Enumerable<ConfiguredU8Split<TSeparator>.Enumerator>
621
{
622
    readonly U8String _value;
623
    readonly TSeparator? _separator;
624
    readonly U8SplitOptions _options;
625

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

633
    public readonly Enumerator GetEnumerator() => new(_value, _separator, _options);
×
634

635
    readonly IEnumerator<U8String> IEnumerable<U8String>.GetEnumerator() => GetEnumerator();
×
636
    readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
×
637

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

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

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

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

686
                if ((_options & U8SplitOptions.RemoveEmpty) is U8SplitOptions.RemoveEmpty
×
687
                    && _current.Length is 0)
×
688
                {
689
                    goto Next;
690
                }
691

692
                return true;
×
693
            }
694

695
            return false;
×
696
        }
697

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

704
        readonly object IEnumerator.Current => Current;
×
705
        readonly void IEnumerator.Reset() => throw new NotSupportedException();
×
706
        readonly void IDisposable.Dispose() { }
×
707
    }
708
}
709

710
// // TODO:
711
// public ref struct U8RefSplit
712
// {
713
//     readonly U8String _value;
714
//     readonly ReadOnlySpan<byte> _separator;
715
//     // Can't force JIT/ILC to emit proper layout here which is sad, and explicit layout ruins codegen
716
//     // int _count;
717
// }
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