How to convert core::fmt::Arguments type for a string in Rust?


#1

I would like to convert a core::fmt::Arguments type for a string type in rust. However, since the fields of Arguments is private, I cannot directly convert it in to a string.

Can anyone advice on how to do this?


#2

Do you mean that you want to create a formatted string?

Arguments implements Display, so you could just use format!("{}", args). If you already have a string buffer, you can also write it directly, s.write_fmt(args).


#3

You can just call .to_string().