I want to format a timestamp obtained from a system call.

C: strftime() is available everywhere and no memory allocation needed.

Rust: Nothing in the standard lib, choose between various crates that can do this, figure out how to convert between SystemTime and whatever the crate has. Everything returns a newly allocated string.

All in all I wouldn't want to go back to C, but not everything is easier in in . :blobshrug:

Follow

Turns out I was (probably) wrong about the memory allocation part. Both the time and humantime crates have types that implement the Display trait, these can be used in a non-allocating manner and are (presumably) more efficient than allocating new strings.

(I haven't benchmarked a thing yet)

Sign in to participate in the conversation
niu.moe

Welcome to your niu world ! We are a cute and loving international community O(≧▽≦)O !
We are a moderated instance, that aren't supporting harassment nor hateful speech. But we aren't a "safe" space, we won't prevent you to interact with instances that aren't respecting our rules.
"Be conservative in what you send and liberal in what you receive." - Netiquette
The main language used here is English, but for most of us this isn't our main language, so it's a great place to learn!