1 module nxt.unsafe;
2 
3 /** Call the possibly unsafe function `fn` in a @trusted way.
4  *
5  * See_Also: https://forum.dlang.org/post/amvspqyavdavzgjegkzt@forum.dlang.org
6  *
7  * TODO Add to std.meta or std.typecons.
8  */
9 template unsafe(alias fn)
10 {
11     auto unsafe(T...)(T args) @trusted
12     {
13         return fn(args);
14     }
15 }
16 
17 //
18 @safe unittest
19 {
20     static @system void dummy(int n) {}
21     unsafe!({ dummy(42); });
22     unsafe!dummy(42);
23 }