]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/language-features/intrinsics.md
Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwco
[rust.git] / src / doc / unstable-book / src / language-features / intrinsics.md
1 # `intrinsics`
2
3 The tracking issue for this feature is: None.
4
5 Intrinsics are never intended to be stable directly, but intrinsics are often
6 exported in some sort of stable manner. Prefer using the stable interfaces to
7 the intrinsic directly when you can.
8
9 ------------------------
10
11
12 These are imported as if they were FFI functions, with the special
13 `rust-intrinsic` ABI. For example, if one was in a freestanding
14 context, but wished to be able to `transmute` between types, and
15 perform efficient pointer arithmetic, one would import those functions
16 via a declaration like
17
18 ```rust
19 #![feature(intrinsics)]
20 # fn main() {}
21
22 extern "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
29 As with any other FFI functions, these are always `unsafe` to call.