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

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?

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).

1 Like

You can just call .to_string().

2 Likes