rust/src/libcore
Ariel Ben-Yehuda 9d074473da 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)
2017-04-05 23:01:08 +00:00
..
benches Extract collections benchmarks to libcollections/benches 2017-02-06 21:38:47 +11:00
fmt Change how the 0 flag works in format! for floats 2017-03-15 07:50:44 -07:00
hash Rollup merge of #40505 - frewsxcv:hash-docs, r=alexcrichton 2017-03-17 08:49:03 -04:00
iter Rollup merge of #40715 - manuel-rhdt:patch-1, r=brson 2017-03-23 08:42:48 -05:00
num Replace ^ with <sup> html balise 2017-04-03 21:17:47 +02:00
prelude Run rustfmt on libcore/prelude folder 2016-10-16 22:13:04 +05:30
slice Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichton 2017-04-05 23:01:08 +00:00
str Rollup merge of #40997 - donniebishop:from_utf8_linking, r=steveklabnik 2017-04-05 12:44:30 -04:00
sync Rollup merge of #40927 - stjepang:docs-atomic-overflow-note, r=alexcrichton 2017-04-05 23:01:07 +00:00
any.rs Various fixes to wording consistency in the docs 2017-03-22 17:19:52 +01:00
array.rs std: Correct stability attributes for some implementations 2016-10-01 23:58:14 +01:00
borrow.rs Use #[prelude_import] in libcore. 2016-08-24 22:12:23 +00:00
Cargo.toml Extract collections benchmarks to libcollections/benches 2017-02-06 21:38:47 +11:00
cell.rs Stabilize move_cell feature, closes #39264 2017-03-17 13:28:37 -07:00
char.rs Fix typo in libcore/char.rs 2017-03-29 16:50:09 +05:30
char_private.rs Reduce a table used for Debug impl of str. 2017-04-05 09:13:19 -07:00
clone.rs Remove function invokation parens from documentation links. 2017-03-13 21:43:18 -04:00
cmp.rs cmp: Implement all PartialOrd methods for Reverse 2017-03-30 17:29:19 +02:00
convert.rs Auto merge of #40281 - jimmycuadra:try-from-from-str, r=aturon 2017-03-20 05:36:36 +00:00
default.rs Bump version, upgrade bootstrap 2017-02-03 13:25:46 -08:00
internal_macros.rs Fix a few impl stability attributes 2017-01-29 13:31:47 +00:00
intrinsics.rs Rollup merge of #41066 - steveklabnik:fix-links, r=frewsxcv 2017-04-05 12:44:38 -04:00
iter_private.rs Various fixes to wording consistency in the docs 2017-03-22 17:19:52 +01:00
lib.rs Implement feature sort_unstable 2017-03-21 20:46:20 +01:00
macros.rs Improve the docs for the write and writeln macros 2017-03-30 14:40:10 -05:00
marker.rs Remove function invokation parens from documentation links. 2017-03-13 21:43:18 -04:00
mem.rs Fix up various links 2017-03-20 10:10:16 -04:00
nonzero.rs Bump version, upgrade bootstrap 2017-02-03 13:25:46 -08:00
ops.rs Don't stutter in operator descriptions #29365 2017-03-25 09:06:14 +00:00
option.rs Minor changes to core::option docs 2017-04-02 06:10:34 +05:30
panicking.rs Mark all extern functions as nounwind 2015-09-14 11:36:09 +02:00
ptr.rs Add tracking issue for offset_to 2017-04-05 07:45:44 +01:00
raw.rs Fix up various links 2017-03-20 10:10:16 -04:00
result.rs Fix external doc errors 2017-03-28 11:38:55 -06:00
tuple.rs Remove macro work-around. 2016-11-12 12:47:13 -07:00