From 46df1037866efd73278aa0f4116a77dbce1edbd8 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 10 Sep 2024 18:03:26 -0700 Subject: [PATCH] add missing stdlib Span extension --- Sources/Future/StdlibSpanExtensions.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/Future/StdlibSpanExtensions.swift b/Sources/Future/StdlibSpanExtensions.swift index 5d8b2382..90f499a2 100644 --- a/Sources/Future/StdlibSpanExtensions.swift +++ b/Sources/Future/StdlibSpanExtensions.swift @@ -493,4 +493,12 @@ extension Span where Element: BitwiseCopyable { } } +extension RawSpan { + public consuming func withBytes( + _ body: (_ elements: RawSpan) throws(E) -> Result + ) throws(E) -> Result { + try body(self) + } +} + //TODO: extend SIMD vectors with `withSpan` and with `withBytes`.