1 module grain.utility;
2 
3 import std.typecons  : isTuple, tuple;
4 
5 
6 auto toTuple(T)(T t) {
7     static if (isTuple!T) {
8         return t;
9     } else {
10         return tuple(t);
11     }
12 }
13 
14 auto fromTuple(T)(T t) {
15     static if (t.length == 0) {
16         return t[0];
17     } else {
18         return t;
19     }
20 }
21 
22 Dst[N] castArray(Dst, Src, size_t N)(Src[N] src) {
23     Dst[N] dst;
24     static foreach (i; 0 .. N) {
25         dst[i] = src[i];
26     }
27     return dst;
28 }
29 
30 version (LDC) {
31     public import ldc.attributes : optStrategy;
32 } else {
33     /// usage @optStrategy("none")
34     struct optStrategy {
35         string s;
36     }
37 }