Clarification of @trusted attribute?

Kenji Hara k.hara.pg at gmail.com
Thu Jun 13 02:56:19 PDT 2013


On Wednesday, 12 June 2013 at 13:09:40 UTC, Gary Willoughby wrote:
> So would you mark the following with @trusted? The format() 
> function is not @safe but what is @trusted really trying to 
> say? This method is @safe as far as i'm concerned? The 
> arguments make format() @safe? I'm confused.
>
> 	/**
> 	 * Get the current timestamp for the log.
> 	 *
> 	 * Returns:
> 	 *     The current timestamp.
> 	 */
> 	private string getTimestamp() const
> 	{
> 		auto time = Clock.currTime();
> 		return format("%d/%02d/%02d %d:%02d:%02d", time.year, 
> time.month, time.day, time.hour, time.minute, time.second);
> 	}

In this case, format std.string.format function should work under 
the `safe annotation.

I recently worked to make it possible.
https://github.com/D-Programming-Language/phobos/pull/1337

Kenji Hara


More information about the Digitalmars-d-learn mailing list