Thanks for replying.

On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
On 05/04/2018 06:33 PM, Neia Neutuladh wrote:
auto asDelegate(TFunc)(TFunc func) @trusted
{
     import std.functional : toDelegate;
     return toDelegate(func);
}

The "@trusted" means that you promise this thing is safe, even if the compiler can't be certain.

If toDelegate isn't (always) @safe, how can you be sure that your wrapper is? Also, TFunc may have an unsafe destructor.

That's not good use of `@trusted`.

Could you elaborate on the unsafe destructor please? Are there any other gotchas ?

Reply via email to