@@ -356,52 +356,6 @@ public static bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> v
356
356
}
357
357
}
358
358
359
- /// <summary>
360
- /// Casts a Span of one primitive type <typeparamref name="T"/> to Span of bytes.
361
- /// That type may not contain pointers or references. This is checked at runtime in order to preserve type safety.
362
- /// </summary>
363
- /// <param name="span">The source slice, of type <typeparamref name="T"/>.</param>
364
- /// <exception cref="System.ArgumentException">
365
- /// Thrown when <typeparamref name="T"/> contains pointers.
366
- /// </exception>
367
- /// <exception cref="System.OverflowException">
368
- /// Thrown if the Length property of the new Span would exceed Int32.MaxValue.
369
- /// </exception>
370
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
371
- public static Span < byte > AsBytes < T > ( this Span < T > span )
372
- where T : struct
373
- {
374
- if ( RuntimeHelpers . IsReferenceOrContainsReferences < T > ( ) )
375
- ThrowHelper . ThrowInvalidTypeWithPointersNotSupported ( typeof ( T ) ) ;
376
-
377
- return new Span < byte > (
378
- ref Unsafe . As < T , byte > ( ref MemoryMarshal . GetReference ( span ) ) ,
379
- checked ( span . Length * Unsafe . SizeOf < T > ( ) ) ) ;
380
- }
381
-
382
- /// <summary>
383
- /// Casts a ReadOnlySpan of one primitive type <typeparamref name="T"/> to ReadOnlySpan of bytes.
384
- /// That type may not contain pointers or references. This is checked at runtime in order to preserve type safety.
385
- /// </summary>
386
- /// <param name="span">The source slice, of type <typeparamref name="T"/>.</param>
387
- /// <exception cref="System.ArgumentException">
388
- /// Thrown when <typeparamref name="T"/> contains pointers.
389
- /// </exception>
390
- /// <exception cref="System.OverflowException">
391
- /// Thrown if the Length property of the new Span would exceed Int32.MaxValue.
392
- /// </exception>
393
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
394
- public static ReadOnlySpan < byte > AsBytes < T > ( this ReadOnlySpan < T > span )
395
- where T : struct
396
- {
397
- if ( RuntimeHelpers . IsReferenceOrContainsReferences < T > ( ) )
398
- ThrowHelper . ThrowInvalidTypeWithPointersNotSupported ( typeof ( T ) ) ;
399
-
400
- return new ReadOnlySpan < byte > (
401
- ref Unsafe . As < T , byte > ( ref MemoryMarshal . GetReference ( span ) ) ,
402
- checked ( span . Length * Unsafe . SizeOf < T > ( ) ) ) ;
403
- }
404
-
405
359
/// <summary>
406
360
/// Creates a new span over the portion of the target array.
407
361
/// </summary>
0 commit comments