rustWhat is null pointer in Rust
A null pointer in Rust is a pointer that does not point to any valid object. It is represented by the type std::ptr::null()
. It is used to indicate that a pointer is not pointing to a valid object.
Example code
let ptr: *const i32 = std::ptr::null();
Output example
ptr: *const i32 = 0x0
Code explanation
let ptr: *const i32
: declares a pointerptr
of type*const i32
std::ptr::null()
: returns a null pointer of type*const T
Helpful links
Related
More of Rust
- How to use a custom hash function with a Rust HashMap?
- How to replace strings using Rust regex?
- How to split a string with Rust regex?
- How to yield return in Rust?
- How to calculate the sum of a Rust slice?
- Yield example in Rust
- How to convert a Rust slice to a fixed array?
- How to convert the keys of a Rust HashMap to a vector?
- How to convert a slice of bytes to a string in Rust?
- How to match whitespace with a regex in Rust?
See more codes...