Skip to content

Commit 862babe

Browse files
committed
added nullptr example
1 parent 43b6a26 commit 862babe

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ in a controlled repository now.
4848
* `debug-macro-rep.rs`: example of macro with varargs
4949
* `macro-nargs.rs`: example of recursive macro
5050
* `macro-tt.rs`: macro token tree example
51+
* `nullptr.rs`: null pointer example

nullptr.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
let mut p: * const u32 = std::ptr::null::<u32>();
3+
println!("{:?}", p);
4+
println!("{:?}", p.is_null());
5+
p = p.wrapping_add(1);
6+
println!("{:?}", p);
7+
8+
let p: *const u8 = "🦀ello".as_ptr();
9+
println!("{}", unsafe { (*p) as char });
10+
}

0 commit comments

Comments
 (0)