浏览代码

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

Bazzagibbs 10 月之前
父节点
当前提交
25be3dfca0
共有 1 个文件被更改,包括 6 次插入0 次删除
  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)