Why are you using D instead of Rust?

jfondren julian.fondren at gmail.com
Sat Oct 23 11:42:26 UTC 2021


On Saturday, 23 October 2021 at 11:36:58 UTC, ag0aep6g wrote:
> On 23.10.21 09:53, jfondren wrote:
>> bool encryptsTo(const(char)* key, const(char)* salt, 
>> const(char)* hash) @trusted {
>>      import std.string : fromStringz;
>> 
>>      return hash.fromStringz == crypt(key, salt).fromStringz;
>> }
>
> That function can't be @trusted. "Any function that traverses a 
> C string passed as an argument can only be @system."
>
> https://dlang.org/spec/function.html#safe-interfaces

Fair enough. The extra types of the Rust version are one solution 
to that if a @trusted interface is still wanted. But since in d 
this function is so trivial, what I actually did was inline it in 
a safer function that only accepted a string.


More information about the Digitalmars-d mailing list