about summary refs log tree commit diff
path: root/src/test/run-pass/thinlto
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2017-04-05 23:01:08 +0000
committerGitHub <noreply@github.com>2017-04-05 23:01:08 +0000
commit9d074473da5fef4b1d9ebbbb7f181edcb7a365a0 (patch)
tree4c1ecbe25d9034e8a32979bf577c0de93e64da50 /src/test/run-pass/thinlto
parentfc5ff66b04af18b42a5278f1f74875311c957555 (diff)
parent1f70247446914a8b58bd088f32bcca792d30d75f (diff)
downloadrust-9d074473da5fef4b1d9ebbbb7f181edcb7a365a0.tar.gz
rust-9d074473da5fef4b1d9ebbbb7f181edcb7a365a0.zip
Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichton
Add ptr::offset_to

This PR adds a method to calculate the signed distance (in number of elements) between two pointers. The resulting value can then be passed to `offset` to get one pointer from the other. This is similar to pointer subtraction in C/C++.

There are 2 special cases:

- If the distance is not a multiple of the element size then the result is rounded towards zero. (in C/C++ this is UB)
-  ZST return `None`, while normal types return `Some(isize)`. This forces the user to handle the ZST case in unsafe code. (C/C++ doesn't have ZSTs)
Diffstat (limited to 'src/test/run-pass/thinlto')
0 files changed, 0 insertions, 0 deletions