Skip to content

Commit 2b0c0ce

Browse files
committed
move array 'length' primitive & add unittest
1 parent b6dfc14 commit 2b0c0ce

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

source/mir/array/primitives.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,16 @@ unittest
172172
ar.popBackExactly!0(1); // Slice-like API
173173
assert(ar == []);
174174
}
175+
176+
///
177+
size_t length(size_t d : 0, T)(T[] array)
178+
{
179+
pragma(inline, true);
180+
return array.length;
181+
}
182+
183+
///
184+
unittest
185+
{
186+
assert([1, 2].length!0 == 2);
187+
}

source/mir/primitives.d

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,5 @@ template DimensionCount(T)
7575
enum size_t DimensionCount = 1;
7676
}
7777

78-
///
79-
size_t length(size_t d : 0, T)(T[] array)
80-
{
81-
pragma(inline, true);
82-
return array.length;
83-
}
84-
8578
///
8679
alias elementsCount = length;

0 commit comments

Comments
 (0)