2015-03-25 17:35:51 -05:00
|
|
|
% Intrinsics
|
|
|
|
|
|
|
|
> **Note**: intrinsics will forever have an unstable interface, it is
|
|
|
|
> recommended to use the stable interfaces of libcore rather than intrinsics
|
|
|
|
> directly.
|
|
|
|
|
|
|
|
These are imported as if they were FFI functions, with the special
|
|
|
|
`rust-intrinsic` ABI. For example, if one was in a freestanding
|
|
|
|
context, but wished to be able to `transmute` between types, and
|
|
|
|
perform efficient pointer arithmetic, one would import those functions
|
|
|
|
via a declaration like
|
|
|
|
|
2015-05-18 13:56:00 -05:00
|
|
|
```rust
|
2015-07-27 09:50:19 -05:00
|
|
|
#![feature(intrinsics)]
|
2015-03-25 17:35:51 -05:00
|
|
|
# fn main() {}
|
|
|
|
|
|
|
|
extern "rust-intrinsic" {
|
|
|
|
fn transmute<T, U>(x: T) -> U;
|
|
|
|
|
|
|
|
fn offset<T>(dst: *const T, offset: isize) -> *const T;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
As with any other FFI functions, these are always `unsafe` to call.
|
|
|
|
|