]> git.proxmox.com Git - rustc.git/blame - src/doc/unstable-book/src/language-features/intrinsics.md
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / doc / unstable-book / src / language-features / intrinsics.md
CommitLineData
8bb4bdeb
XL
1# `intrinsics`
2
3The tracking issue for this feature is: None.
4
5Intrinsics are never intended to be stable directly, but intrinsics are often
6exported in some sort of stable manner. Prefer using the stable interfaces to
7the intrinsic directly when you can.
8
9------------------------
c34b1796 10
c34b1796
AL
11
12These are imported as if they were FFI functions, with the special
13`rust-intrinsic` ABI. For example, if one was in a freestanding
14context, but wished to be able to `transmute` between types, and
15perform efficient pointer arithmetic, one would import those functions
16via a declaration like
17
62682a34 18```rust
c1a9b12d 19#![feature(intrinsics)]
c34b1796
AL
20# fn main() {}
21
22extern "rust-intrinsic" {
23 fn transmute<T, U>(x: T) -> U;
24
25 fn offset<T>(dst: *const T, offset: isize) -> *const T;
26}
27```
28
29As with any other FFI functions, these are always `unsafe` to call.