]> git.lizzy.rs Git - rust.git/blob - src/test/ui/offset_from.rs
Rollup merge of #68253 - japaric:bare-metal-cortex-a, r=alexcrichton
[rust.git] / src / test / ui / offset_from.rs
1 // run-pass
2
3 #![feature(ptr_offset_from)]
4
5 fn main() {
6     let mut a = [0; 5];
7     let ptr1: *mut i32 = &mut a[1];
8     let ptr2: *mut i32 = &mut a[3];
9     unsafe {
10         assert_eq!(ptr2.offset_from(ptr1), 2);
11         assert_eq!(ptr1.offset_from(ptr2), -2);
12         assert_eq!(ptr1.offset(2), ptr2);
13         assert_eq!(ptr2.offset(-2), ptr1);
14     }
15 }