Pointers
Printing Pointers
You can print pointers with {:p}
formatter and *const
with {:?}
formatter.
main.rs
Meaning behind {:?}
It means to debug-format a value.
First, the type of the value should derive Debug
trait like this:
And then you can use :?
formatter to print it or store its formatted value.
{}
surrounds formatting directives.:
separates the name / ordinal of the value being formatted. In this case({:?}
), it's omitted.?
is the formatting option that triggers the use of thestd::fmt::Debug
implementation of the value being formatted. (as opposed to the defaultDisplay
trait)
Last updated