Skip to content

Commit 943f9aa

Browse files
committed
auto merge of rust-lang#8692 : kballard/rust/ffi-tutorial-c_str, r=huonw
The FFI tutorial still incorrectly stated that strings were terminated with
2 parents 4edf375 + fe1beac commit 943f9aa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

doc/tutorial-ffi.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,8 @@ prefer using raw pointers (`*`) if that's needed because the compiler can't make
445445
about them.
446446

447447
Vectors and strings share the same basic memory layout, and utilities are available in the `vec` and
448-
`str` modules for working with C APIs. Strings are terminated with `\0` for interoperability with C,
449-
but it should not be assumed because a slice will not always be nul-terminated. Instead, the
450-
`str::as_c_str` function should be used.
448+
`str` modules for working with C APIs. However, strings are not terminated with `\0`. If you need a
449+
NUL-terminated string for interoperability with C, you should use the `c_str::to_c_str` function.
451450

452451
The standard library includes type aliases and function definitions for the C standard library in
453452
the `libc` module, and Rust links against `libc` and `libm` by default.

0 commit comments

Comments
 (0)