Trait Pointer
trait Pointer: PointeeSized
p formatting.
The Pointer trait should format its output as a memory location. This is commonly presented
as hexadecimal. For more information on formatters, see the module-level documentation.
Printing of pointers is not a reliable way to discover how Rust programs are implemented. The act of reading an address changes the program itself, and may change how the data is represented in memory, and may affect which optimizations are applied to the code.
The printed pointer values are not guaranteed to be stable nor unique identifiers of objects. Rust allows moving values to different memory locations, and may reuse the same memory locations for different purposes.
There is no guarantee that the printed value can be converted back to a pointer.
Examples
Basic usage with &i32:
let x = &42;
let address = format!; // this produces something like '0x7f06092ac6d0'
Implementing Pointer on a type:
use fmt;
;
let l = Length;
println!;
let l_ptr = format!;
assert_eq!;
assert_eq!;
Required Methods
fn fmt(self: &Self, f: &mut Formatter<'_>) -> ResultFormats the value using the given formatter.
Errors
This function should return
Errif, and only if, the providedFormatterreturnsErr. String formatting is considered an infallible operation; this function only returns aResultbecause writing to the underlying stream might fail and it must provide a way to propagate the fact that an error has occurred back up the stack.
Implementors
impl<T: PointeeSized> Pointer for *mut Timpl<T: PointeeSized> Pointer for &Timpl<T: PointeeSized> Pointer for &mut Timpl<T: PointeeSized> Pointer for NonNull<T>impl<T> Pointer for AtomicPtr<T>impl<F: FnPtr> Pointer for Fimpl<Ptr: fmt::Pointer> Pointer for Pin<Ptr>impl<F> Pointer for fn(_: T) -> Retimpl<T: PointeeSized> Pointer for *const T