Is `String::with_capacity()` equal to `malloc`?
04:31 21 Jun 2017

I read this article a few days ago and I thought what is the best way to implement such a thing in Rust. The article suggests to use a buffer instead of printing the string after each iteration.

Is this correct to say String::with_capacity() (or Vec) is equal to malloc in C?

Example from the codes:

String::with_capacity(size * 4096)

equal to:

char *buf = malloc(size * 4096);
memory-management rust