Explorar o código

Add core:slice.size to get the byte size of a slice's backing data

Bazzagibbs hai 10 meses
pai
achega
25be3dfca0
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      core/slice/slice.odin

+ 6 - 0
core/slice/slice.odin

@@ -471,6 +471,12 @@ is_empty :: proc(a: $T/[]$E) -> bool {
 	return len(a) == 0
 }
 
+// Gets the byte size of the backing data
+@(require_results)
+size :: proc "contextless" (a: $T/[]$E) -> int {
+	return len(a) * size_of(E)
+}
+
 
 
 @(require_results)