Skip to content

Commit 5fb8e3d

Browse files
ffi/mod.rs: Use only one space after a period ending a sentence
1 parent c8e232d commit 5fb8e3d

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/libstd/ffi/mod.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@
1212
//!
1313
//! This module provides utilities to handle data across non-Rust
1414
//! interfaces, like other programming languages and the underlying
15-
//! operating system. It is mainly of use for FFI (Foreign Function
15+
//! operating system. It is mainly of use for FFI (Foreign Function
1616
//! Interface) bindings and code that needs to exchange C-like strings
1717
//! with other languages.
1818
//!
1919
//! # Overview
2020
//!
2121
//! Rust represents owned strings with the [`String`] type, and
22-
//! borrowed slices of strings with the [`str`] primitive. Both are
22+
//! borrowed slices of strings with the [`str`] primitive. Both are
2323
//! always in UTF-8 encoding, and may contain nul bytes in the middle,
2424
//! i.e. if you look at the bytes that make up the string, there may
25-
//! be a `\0` among them. Both `String` and `str` store their length
25+
//! be a `\0` among them. Both `String` and `str` store their length
2626
//! explicitly; there are no nul terminators at the end of strings
2727
//! like in C.
2828
//!
2929
//! C strings are different from Rust strings:
3030
//!
3131
//! * **Encodings** - Rust strings are UTF-8, but C strings may use
32-
//! other encodings. If you are using a string from C, you should
32+
//! other encodings. If you are using a string from C, you should
3333
//! check its encoding explicitly, rather than just assuming that it
3434
//! is UTF-8 like you can do in Rust.
3535
//!
3636
//! * **Character size** - C strings may use `char` or `wchar_t`-sized
3737
//! characters; please **note** that C's `char` is different from Rust's.
3838
//! The C standard leaves the actual sizes of those types open to
3939
//! interpretation, but defines different APIs for strings made up of
40-
//! each character type. Rust strings are always UTF-8, so different
40+
//! each character type. Rust strings are always UTF-8, so different
4141
//! Unicode characters will be encoded in a variable number of bytes
42-
//! each. The Rust type [`char`] represents a '[Unicode scalar
42+
//! each. The Rust type [`char`] represents a '[Unicode scalar
4343
//! value]', which is similar to, but not the same as, a '[Unicode
4444
//! code point]'.
4545
//!
4646
//! * **Nul terminators and implicit string lengths** - Often, C
4747
//! strings are nul-terminated, i.e. they have a `\0` character at the
48-
//! end. The length of a string buffer is not stored, but has to be
48+
//! end. The length of a string buffer is not stored, but has to be
4949
//! calculated; to compute the length of a string, C code must
5050
//! manually call a function like `strlen()` for `char`-based strings,
51-
//! or `wcslen()` for `wchar_t`-based ones. Those functions return
51+
//! or `wcslen()` for `wchar_t`-based ones. Those functions return
5252
//! the number of characters in the string excluding the nul
5353
//! terminator, so the buffer length is really `len+1` characters.
5454
//! Rust strings don't have a nul terminator; their length is always
55-
//! stored and does not need to be calculated. While in Rust
55+
//! stored and does not need to be calculated. While in Rust
5656
//! accessing a string's length is a O(1) operation (becasue the
5757
//! length is stored); in C it is an O(length) operation because the
5858
//! length needs to be computed by scanning the string for the nul
@@ -61,7 +61,7 @@
6161
//! * **Internal nul characters** - When C strings have a nul
6262
//! terminator character, this usually means that they cannot have nul
6363
//! characters in the middle — a nul character would essentially
64-
//! truncate the string. Rust strings *can* have nul characters in
64+
//! truncate the string. Rust strings *can* have nul characters in
6565
//! the middle, because nul does not have to mark the end of the
6666
//! string in Rust.
6767
//!
@@ -80,30 +80,30 @@
8080
//!
8181
//! * **From C to Rust:** [`CStr`] represents a borrowed C string; it
8282
//! is what you would use to wrap a raw `*const u8` that you got from
83-
//! a C function. A `CStr` is guaranteed to be a nul-terminated array
84-
//! of bytes. Once you have a `CStr`, you can convert it to a Rust
83+
//! a C function. A `CStr` is guaranteed to be a nul-terminated array
84+
//! of bytes. Once you have a `CStr`, you can convert it to a Rust
8585
//! `&str` if it's valid UTF-8, or lossily convert it by adding
8686
//! replacement characters.
8787
//!
8888
//! [`OsString`] and [`OsStr`] are useful when you need to transfer
8989
//! strings to and from the operating system itself, or when capturing
90-
//! the output of external commands. Conversions between `OsString`,
90+
//! the output of external commands. Conversions between `OsString`,
9191
//! `OsStr` and Rust strings work similarly to those for [`CString`]
9292
//! and [`CStr`].
9393
//!
9494
//! * [`OsString`] represents an owned string in whatever
95-
//! representation the operating system prefers. In the Rust standard
95+
//! representation the operating system prefers. In the Rust standard
9696
//! library, various APIs that transfer strings to/from the operating
97-
//! system use `OsString` instead of plain strings. For example,
97+
//! system use `OsString` instead of plain strings. For example,
9898
//! [`env::var_os()`] is used to query environment variables; it
99-
//! returns an `Option<OsString>`. If the environment variable exists
99+
//! returns an `Option<OsString>`. If the environment variable exists
100100
//! you will get a `Some(os_string)`, which you can *then* try to
101-
//! convert to a Rust string. This yields a [`Result<>`], so that
101+
//! convert to a Rust string. This yields a [`Result<>`], so that
102102
//! your code can detect errors in case the environment variable did
103103
//! not in fact contain valid Unicode data.
104104
//!
105105
//! * [`OsStr`] represents a borrowed reference to a string in a
106-
//! format that can be passed to the operating system. It can be
106+
//! format that can be passed to the operating system. It can be
107107
//! converted into an UTF-8 Rust string slice in a similar way to
108108
//! `OsString`.
109109
//!
@@ -125,12 +125,12 @@
125125
//!
126126
//! On Windows, [`OsStr`] implements the
127127
//! `std::os::windows::ffi::`[`OsStrExt`][windows.OsStrExt] trait,
128-
//! which provides an [`encode_wide`] method. This provides an
128+
//! which provides an [`encode_wide`] method. This provides an
129129
//! iterator that can be [`collect`]ed into a vector of [`u16`].
130130
//!
131131
//! Additionally, on Windows [`OsString`] implements the
132132
//! `std::os::windows:ffi::`[`OsStringExt`][windows.OsStringExt]
133-
//! trait, which provides a [`from_wide`] method. The result of this
133+
//! trait, which provides a [`from_wide`] method. The result of this
134134
//! method is an `OsString` which can be round-tripped to a Windows
135135
//! string losslessly.
136136
//!

0 commit comments

Comments
 (0)