1
Fork 0

Various minor/cosmetic improvements to code

This commit is contained in:
Alexander Regueiro 2018-11-27 02:59:49 +00:00
parent 4a45578bc5
commit ee89c088b0
457 changed files with 2384 additions and 2360 deletions

View file

@ -342,7 +342,7 @@ impl<T, S> HashSet<T, S>
}
/// Visits the values representing the difference,
/// i.e. the values that are in `self` but not in `other`.
/// i.e., the values that are in `self` but not in `other`.
///
/// # Examples
///
@ -373,7 +373,7 @@ impl<T, S> HashSet<T, S>
}
/// Visits the values representing the symmetric difference,
/// i.e. the values that are in `self` or in `other` but not in both.
/// i.e., the values that are in `self` or in `other` but not in both.
///
/// # Examples
///
@ -401,7 +401,7 @@ impl<T, S> HashSet<T, S>
}
/// Visits the values representing the intersection,
/// i.e. the values that are both in `self` and `other`.
/// i.e., the values that are both in `self` and `other`.
///
/// # Examples
///
@ -427,7 +427,7 @@ impl<T, S> HashSet<T, S>
}
/// Visits the values representing the union,
/// i.e. all the values in `self` or `other`, without duplicates.
/// i.e., all the values in `self` or `other`, without duplicates.
///
/// # Examples
///
@ -598,7 +598,7 @@ impl<T, S> HashSet<T, S>
}
/// Returns `true` if the set is a subset of another,
/// i.e. `other` contains at least all the values in `self`.
/// i.e., `other` contains at least all the values in `self`.
///
/// # Examples
///
@ -620,7 +620,7 @@ impl<T, S> HashSet<T, S>
}
/// Returns `true` if the set is a superset of another,
/// i.e. `self` contains at least all the values in `other`.
/// i.e., `self` contains at least all the values in `other`.
///
/// # Examples
///

View file

@ -36,12 +36,12 @@ use str;
use string;
/// `Error` is a trait representing the basic expectations for error values,
/// i.e. values of type `E` in [`Result<T, E>`]. Errors must describe
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
/// themselves through the [`Display`] and [`Debug`] traits, and may provide
/// cause chain information:
///
/// The [`cause`] method is generally used when errors cross "abstraction
/// boundaries", i.e. when a one module must report an error that is "caused"
/// boundaries", i.e., when a one module must report an error that is "caused"
/// by an error from a lower-level module. This setup makes it possible for the
/// high-level module to provide its own errors that do not commit to any
/// particular implementation, but also reveal some of its implementation for

View file

@ -888,7 +888,7 @@ impl f64 {
}
// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
// because of their non-standard behavior (e.g. log(-n) returns -Inf instead
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
// of expected NaN).
fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
if !cfg!(target_os = "solaris") {

View file

@ -372,7 +372,7 @@ impl CString {
/// # Safety
///
/// This should only ever be called with a pointer that was earlier
/// obtained by calling [`into_raw`] on a `CString`. Other usage (e.g. trying to take
/// obtained by calling [`into_raw`] on a `CString`. Other usage (e.g., trying to take
/// ownership of a string that was allocated by foreign code) is likely to lead
/// to undefined behavior or allocator corruption.
///
@ -1167,8 +1167,8 @@ impl CStr {
/// ```
#[stable(feature = "cstr_to_str", since = "1.4.0")]
pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
// NB: When CStr is changed to perform the length check in .to_bytes()
// instead of in from_ptr(), it may be worth considering if this should
// N.B., when `CStr` is changed to perform the length check in `.to_bytes()`
// instead of in `from_ptr()`, it may be worth considering if this should
// be rewritten to do the UTF-8 check inline with the length calculation
// instead of doing it afterwards.
str::from_utf8(self.to_bytes())

View file

@ -21,7 +21,7 @@
//! Rust represents owned strings with the [`String`] type, and
//! borrowed slices of strings with the [`str`] primitive. Both are
//! always in UTF-8 encoding, and may contain nul bytes in the middle,
//! i.e. if you look at the bytes that make up the string, there may
//! i.e., if you look at the bytes that make up the string, there may
//! be a `\0` among them. Both `String` and `str` store their length
//! explicitly; there are no nul terminators at the end of strings
//! like in C.
@ -44,7 +44,7 @@
//! code point]'.
//!
//! * **Nul terminators and implicit string lengths** - Often, C
//! strings are nul-terminated, i.e. they have a `\0` character at the
//! strings are nul-terminated, i.e., they have a `\0` character at the
//! end. The length of a string buffer is not stored, but has to be
//! calculated; to compute the length of a string, C code must
//! manually call a function like `strlen()` for `char`-based strings,

View file

@ -36,7 +36,7 @@ use sys_common::{AsInner, IntoInner, FromInner};
/// and platform-native string values, and in particular allowing a Rust string
/// to be converted into an "OS" string with no cost if possible. A consequence
/// of this is that `OsString` instances are *not* `NUL` terminated; in order
/// to pass to e.g. Unix system call, you should create a [`CStr`].
/// to pass to e.g., Unix system call, you should create a [`CStr`].
///
/// `OsString` is to [`&OsStr`] as [`String`] is to [`&str`]: the former
/// in each pair are owned strings; the latter are borrowed

View file

@ -1406,7 +1406,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
/// Removes a file from the filesystem.
///
/// Note that there is no
/// guarantee that the file is immediately deleted (e.g. depending on
/// guarantee that the file is immediately deleted (e.g., depending on
/// platform, other open file descriptors may prevent immediate removal).
///
/// # Platform-specific behavior

View file

@ -90,7 +90,7 @@ pub struct Cursor<T> {
impl<T> Cursor<T> {
/// Creates a new cursor wrapping the provided underlying in-memory buffer.
///
/// Cursor initial position is `0` even if underlying buffer (e.g. `Vec`)
/// Cursor initial position is `0` even if underlying buffer (e.g., `Vec`)
/// is not empty. So writing to cursor starts with overwriting `Vec`
/// content, not with appending to it.
///

View file

@ -131,7 +131,7 @@ fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
///
/// Each handle is a shared reference to a global buffer of input data to this
/// process. A handle can be `lock`'d to gain full access to [`BufRead`] methods
/// (e.g. `.lines()`). Reads to this handle are otherwise locked with respect
/// (e.g., `.lines()`). Reads to this handle are otherwise locked with respect
/// to other reads.
///
/// This handle implements the `Read` trait, but beware that concurrent reads
@ -269,7 +269,7 @@ impl Stdin {
///
/// You can run the example one of two ways:
///
/// - Pipe some text to it, e.g. `printf foo | path/to/executable`
/// - Pipe some text to it, e.g., `printf foo | path/to/executable`
/// - Give it text interactively by running the executable directly,
/// in which case it will wait for the Enter key to be pressed before
/// continuing

View file

@ -188,7 +188,7 @@ mod enum_keyword { }
/// For external connections in Rust code.
///
/// The `extern` keyword is used in two places in Rust. One is in conjunction with the [`crate`]
/// keyword to make your Rust code aware of other Rust crates in your project, i.e. `extern crate
/// keyword to make your Rust code aware of other Rust crates in your project, i.e., `extern crate
/// lazy_static;`. The other use is in foreign function interfaces (FFI).
///
/// `extern` is used in two different contexts within FFI. The first is in the form of external

View file

@ -703,7 +703,7 @@ impl hash::Hash for SocketAddrV6 {
/// the other: for simple uses a string like `"localhost:12345"` is much nicer
/// than manual construction of the corresponding [`SocketAddr`], but sometimes
/// [`SocketAddr`] value is *the* main source of the address, and converting it to
/// some other type (e.g. a string) just for it to be converted back to
/// some other type (e.g., a string) just for it to be converted back to
/// [`SocketAddr`] in constructor methods is pointless.
///
/// Addresses returned by the operating system that are not IP addresses are

View file

@ -530,7 +530,7 @@ impl TcpStream {
/// Moves this TCP stream into or out of nonblocking mode.
///
/// This will result in `read`, `write`, `recv` and `send` operations
/// becoming nonblocking, i.e. immediately returning from their calls.
/// becoming nonblocking, i.e., immediately returning from their calls.
/// If the IO operation is successful, `Ok` is returned and no further
/// action is required. If the IO operation could not be completed and needs
/// to be retried, an error with kind [`io::ErrorKind::WouldBlock`] is
@ -840,7 +840,7 @@ impl TcpListener {
/// Moves this TCP stream into or out of nonblocking mode.
///
/// This will result in the `accept` operation becoming nonblocking,
/// i.e. immediately returning from their calls. If the IO operation is
/// i.e., immediately returning from their calls. If the IO operation is
/// successful, `Ok` is returned and no further action is required. If the
/// IO operation could not be completed and needs to be retried, an error
/// with kind [`io::ErrorKind::WouldBlock`] is returned.

View file

@ -752,7 +752,7 @@ impl UdpSocket {
/// Moves this UDP socket into or out of nonblocking mode.
///
/// This will result in `recv`, `recv_from`, `send`, and `send_to`
/// operations becoming nonblocking, i.e. immediately returning from their
/// operations becoming nonblocking, i.e., immediately returning from their
/// calls. If the IO operation is successful, `Ok` is returned and no
/// further action is required. If the IO operation could not be completed
/// and needs to be retried, an error with kind

View file

@ -80,7 +80,7 @@ pub use core::panic::{PanicInfo, Location};
/// Simply put, a type `T` implements `UnwindSafe` if it cannot easily allow
/// witnessing a broken invariant through the use of `catch_unwind` (catching a
/// panic). This trait is an auto trait, so it is automatically implemented for
/// many types, and it is also structurally composed (e.g. a struct is unwind
/// many types, and it is also structurally composed (e.g., a struct is unwind
/// safe if all of its components are unwind safe).
///
/// Note, however, that this is not an unsafe trait, so there is not a succinct

View file

@ -460,7 +460,7 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp,
let panics = update_panic_count(1);
// If this is the third nested call (e.g. panics == 2, this is 0-indexed),
// If this is the third nested call (e.g., panics == 2, this is 0-indexed),
// the panic hook probably triggered the last panic, otherwise the
// double-panic check would have aborted the process. In this case abort the
// process real quickly as we don't want to try calling it again as it'll

View file

@ -109,11 +109,11 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
// Windows Prefixes
////////////////////////////////////////////////////////////////////////////////
/// Windows path prefixes, e.g. `C:` or `\\server\share`.
/// Windows path prefixes, e.g., `C:` or `\\server\share`.
///
/// Windows uses a variety of path prefix styles, including references to drive
/// volumes (like `C:`), network shared folders (like `\\server\share`), and
/// others. In addition, some path prefixes are "verbatim" (i.e. prefixed with
/// others. In addition, some path prefixes are "verbatim" (i.e., prefixed with
/// `\\?\`), in which case `/` is *not* treated as a separator and essentially
/// no normalization is performed.
///
@ -148,7 +148,7 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
#[derive(Copy, Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Prefix<'a> {
/// Verbatim prefix, e.g. `\\?\cat_pics`.
/// Verbatim prefix, e.g., `\\?\cat_pics`.
///
/// Verbatim prefixes consist of `\\?\` immediately followed by the given
/// component.
@ -156,7 +156,7 @@ pub enum Prefix<'a> {
Verbatim(#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr),
/// Verbatim prefix using Windows' _**U**niform **N**aming **C**onvention_,
/// e.g. `\\?\UNC\server\share`.
/// e.g., `\\?\UNC\server\share`.
///
/// Verbatim UNC prefixes consist of `\\?\UNC\` immediately followed by the
/// server's hostname and a share name.
@ -166,14 +166,14 @@ pub enum Prefix<'a> {
#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr,
),
/// Verbatim disk prefix, e.g. `\\?\C:\`.
/// Verbatim disk prefix, e.g., `\\?\C:\`.
///
/// Verbatim disk prefixes consist of `\\?\` immediately followed by the
/// drive letter and `:\`.
#[stable(feature = "rust1", since = "1.0.0")]
VerbatimDisk(#[stable(feature = "rust1", since = "1.0.0")] u8),
/// Device namespace prefix, e.g. `\\.\COM42`.
/// Device namespace prefix, e.g., `\\.\COM42`.
///
/// Device namespace prefixes consist of `\\.\` immediately followed by the
/// device name.
@ -227,7 +227,7 @@ impl<'a> Prefix<'a> {
}
/// Determines if the prefix is verbatim, i.e. begins with `\\?\`.
/// Determines if the prefix is verbatim, i.e., begins with `\\?\`.
///
/// # Examples
///
@ -509,7 +509,7 @@ impl<'a> Hash for PrefixComponent<'a> {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Component<'a> {
/// A Windows path prefix, e.g. `C:` or `\\server\share`.
/// A Windows path prefix, e.g., `C:` or `\\server\share`.
///
/// There is a large variety of prefix types, see [`Prefix`]'s documentation
/// for more.
@ -528,15 +528,15 @@ pub enum Component<'a> {
#[stable(feature = "rust1", since = "1.0.0")]
RootDir,
/// A reference to the current directory, i.e. `.`.
/// A reference to the current directory, i.e., `.`.
#[stable(feature = "rust1", since = "1.0.0")]
CurDir,
/// A reference to the parent directory, i.e. `..`.
/// A reference to the parent directory, i.e., `..`.
#[stable(feature = "rust1", since = "1.0.0")]
ParentDir,
/// A normal component, e.g. `a` and `b` in `a/b`.
/// A normal component, e.g., `a` and `b` in `a/b`.
///
/// This variant is the most common one, it represents references to files
/// or directories.
@ -615,7 +615,7 @@ pub struct Components<'a> {
// true if path *physically* has a root separator; for most Windows
// prefixes, it may have a "logical" rootseparator for the purposes of
// normalization, e.g. \\server\share == \\server\share\.
// normalization, e.g., \\server\share == \\server\share\.
has_physical_root: bool,
// The iterator is double-ended, and these two states keep track of what has
@ -798,7 +798,7 @@ impl<'a> Components<'a> {
(comp.len() + extra, self.parse_single_component(comp))
}
// trim away repeated separators (i.e. empty components) on the left
// trim away repeated separators (i.e., empty components) on the left
fn trim_left(&mut self) {
while !self.path.is_empty() {
let (size, comp) = self.parse_next_component();
@ -810,7 +810,7 @@ impl<'a> Components<'a> {
}
}
// trim away repeated separators (i.e. empty components) on the right
// trim away repeated separators (i.e., empty components) on the right
fn trim_right(&mut self) {
while self.path.len() > self.len_before_body() {
let (size, comp) = self.parse_next_component_back();
@ -1178,7 +1178,7 @@ impl PathBuf {
///
/// On Windows:
///
/// * if `path` has a root but no prefix (e.g. `\windows`), it
/// * if `path` has a root but no prefix (e.g., `\windows`), it
/// replaces everything except for the prefix (if any) of `self`.
/// * if `path` has a prefix but no root, it replaces `self`.
///
@ -1225,7 +1225,7 @@ impl PathBuf {
if path.is_absolute() || path.prefix().is_some() {
self.as_mut_vec().truncate(0);
// `path` has a root but no prefix, e.g. `\windows` (Windows only)
// `path` has a root but no prefix, e.g., `\windows` (Windows only)
} else if path.has_root() {
let prefix_len = self.components().prefix_remaining();
self.as_mut_vec().truncate(prefix_len);
@ -1810,7 +1810,7 @@ impl Path {
PathBuf::from(self.inner.to_os_string())
}
/// Returns `true` if the `Path` is absolute, i.e. if it is independent of
/// Returns `true` if the `Path` is absolute, i.e., if it is independent of
/// the current directory.
///
/// * On Unix, a path is absolute if it starts with the root, so
@ -1839,7 +1839,7 @@ impl Path {
}
}
/// Returns `true` if the `Path` is relative, i.e. not absolute.
/// Returns `true` if the `Path` is relative, i.e., not absolute.
///
/// See [`is_absolute`]'s documentation for more details.
///
@ -1866,9 +1866,9 @@ impl Path {
/// * On Unix, a path has a root if it begins with `/`.
///
/// * On Windows, a path has a root if it:
/// * has no prefix and begins with a separator, e.g. `\windows`
/// * has a prefix followed by a separator, e.g. `c:\windows` but not `c:windows`
/// * has any non-disk prefix, e.g. `\\server\share`
/// * has no prefix and begins with a separator, e.g., `\windows`
/// * has a prefix followed by a separator, e.g., `c:\windows` but not `c:windows`
/// * has any non-disk prefix, e.g., `\\server\share`
///
/// # Examples
///
@ -1980,7 +1980,7 @@ impl Path {
///
/// # Errors
///
/// If `base` is not a prefix of `self` (i.e. [`starts_with`]
/// If `base` is not a prefix of `self` (i.e., [`starts_with`]
/// returns `false`), returns [`Err`].
///
/// [`starts_with`]: #method.starts_with
@ -2406,7 +2406,7 @@ impl Path {
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
///
/// If you cannot access the directory containing the file, e.g. because of a
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
///
/// # Examples
@ -2432,7 +2432,7 @@ impl Path {
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
///
/// If you cannot access the directory containing the file, e.g. because of a
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
///
/// # Examples
@ -2461,7 +2461,7 @@ impl Path {
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
///
/// If you cannot access the directory containing the file, e.g. because of a
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
///
/// # Examples

View file

@ -462,7 +462,7 @@ mod prim_pointer { }
///
/// There are two syntactic forms for creating an array:
///
/// * A list with each element, i.e. `[x, y, z]`.
/// * A list with each element, i.e., `[x, y, z]`.
/// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`.
/// The type of `x` must be [`Copy`][copy].
///

View file

@ -628,7 +628,7 @@ impl Command {
///
/// # Platform-specific behavior
///
/// If the program path is relative (e.g. `"./script.sh"`), it's ambiguous
/// If the program path is relative (e.g., `"./script.sh"`), it's ambiguous
/// whether it should be interpreted relative to the parent's working
/// directory or relative to `current_dir`. The behavior in this case is
/// platform specific and unstable, and it's recommended to use

View file

@ -89,7 +89,7 @@
//!
//! - A **single processor** executing instructions [out-of-order]:
//! Modern CPUs are capable of [superscalar] execution,
//! i.e. multiple instructions might be executing at the same time,
//! i.e., multiple instructions might be executing at the same time,
//! even though the machine code describes a sequential process.
//!
//! This kind of reordering is handled transparently by the CPU.

View file

@ -292,7 +292,7 @@ impl<T> Packet<T> {
}
}
// NB: Channel could be disconnected while waiting, so the order of
// N.B., channel could be disconnected while waiting, so the order of
// these conditionals is important.
if guard.disconnected && guard.buf.size() == 0 {
return Err(Disconnected);

View file

@ -189,7 +189,7 @@ impl Once {
/// static INIT: Once = Once::new();
///
/// // Accessing a `static mut` is unsafe much of the time, but if we do so
/// // in a synchronized fashion (e.g. write once or read all) then we're
/// // in a synchronized fashion (e.g., write once or read all) then we're
/// // good to go!
/// //
/// // This function will only call `expensive_computation` once, and will
@ -232,7 +232,7 @@ impl Once {
/// Performs the same function as [`call_once`] except ignores poisoning.
///
/// Unlike [`call_once`], if this `Once` has been poisoned (i.e. a previous
/// Unlike [`call_once`], if this `Once` has been poisoned (i.e., a previous
/// call to `call_once` or `call_once_force` caused a panic), calling
/// `call_once_force` will still invoke the closure `f` and will _not_
/// result in an immediate panic. If `f` panics, the `Once` will remain

View file

@ -15,7 +15,7 @@
//! always work with the most recent version of Android, but we also want to
//! work with older versions of Android for whenever projects need to.
//!
//! Our current minimum supported Android version is `android-9`, e.g. Android
//! Our current minimum supported Android version is `android-9`, e.g., Android
//! with API level 9. We then in theory want to work on that and all future
//! versions of Android!
//!

View file

@ -132,7 +132,7 @@ impl SocketAddr {
if len == 0 {
// When there is a datagram from unnamed unix socket
// linux returns zero bytes of address
len = sun_path_offset() as libc::socklen_t; // i.e. zero-length address
len = sun_path_offset() as libc::socklen_t; // i.e., zero-length address
} else if addr.sun_family != libc::AF_UNIX as libc::sa_family_t {
return Err(io::Error::new(io::ErrorKind::InvalidInput,
"file descriptor did not correspond to a Unix socket"));

View file

@ -26,7 +26,7 @@ pub extern crate libc as netc;
pub type wrlen_t = size_t;
// See below for the usage of SOCK_CLOEXEC, but this constant is only defined on
// Linux currently (e.g. support doesn't exist on other platforms). In order to
// Linux currently (e.g., support doesn't exist on other platforms). In order to
// get name resolution to work and things to compile we just define a dummy
// SOCK_CLOEXEC here for other platforms. Note that the dummy constant isn't
// actually ever used (the blocks below are wrapped in `if cfg!` as well.

View file

@ -215,7 +215,7 @@ pub const FDIO_SPAWN_ACTION_TRANSFER_FD: u32 = 0x0002;
// and has a closed remote end will return ERR_REMOTE_CLOSED.
#[allow(unused)] pub const ERR_SHOULD_WAIT: zx_status_t = -22;
// ERR_CANCELED: The in-progress operation (e.g. a wait) has been
// ERR_CANCELED: The in-progress operation (e.g., a wait) has been
// // canceled.
#[allow(unused)] pub const ERR_CANCELED: zx_status_t = -23;

View file

@ -117,7 +117,7 @@ impl OsStringExt for OsString {
/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait OsStrExt {
/// Re-encodes an `OsStr` as a wide character sequence, i.e. potentially
/// Re-encodes an `OsStr` as a wide character sequence, i.e., potentially
/// ill-formed UTF-16.
///
/// This is lossless: calling [`OsString::from_wide`] and then

View file

@ -443,7 +443,7 @@ impl FromInner<c::HANDLE> for File {
impl fmt::Debug for File {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// FIXME(#24570): add more info here (e.g. mode)
// FIXME(#24570): add more info here (e.g., mode)
let mut b = f.debug_struct("File");
b.field("handle", &self.handle.raw());
if let Ok(path) = get_path(&self) {

View file

@ -67,7 +67,7 @@ pub fn error_string(mut errnum: i32) -> String {
buf.len() as c::DWORD,
ptr::null()) as usize;
if res == 0 {
// Sometimes FormatMessageW can fail e.g. system doesn't like langId,
// Sometimes FormatMessageW can fail e.g., system doesn't like langId,
let fm_err = errno();
return format!("OS Error {} (FormatMessageW() returned error {})",
errnum, fm_err);

View file

@ -100,23 +100,23 @@ pub fn anon_pipe(ours_readable: bool) -> io::Result<Pipes> {
0,
ptr::null_mut());
// We pass the FILE_FLAG_FIRST_PIPE_INSTANCE flag above, and we're
// We pass the `FILE_FLAG_FIRST_PIPE_INSTANCE` flag above, and we're
// also just doing a best effort at selecting a unique name. If
// ERROR_ACCESS_DENIED is returned then it could mean that we
// `ERROR_ACCESS_DENIED` is returned then it could mean that we
// accidentally conflicted with an already existing pipe, so we try
// again.
//
// Don't try again too much though as this could also perhaps be a
// legit error.
// If ERROR_INVALID_PARAMETER is returned, this probably means we're
// running on pre-Vista version where PIPE_REJECT_REMOTE_CLIENTS is
// If `ERROR_INVALID_PARAMETER` is returned, this probably means we're
// running on pre-Vista version where `PIPE_REJECT_REMOTE_CLIENTS` is
// not supported, so we continue retrying without it. This implies
// reduced security on Windows versions older than Vista by allowing
// connections to this pipe from remote machines.
// Proper fix would increase the number of FFI imports and introduce
// significant amount of Windows XP specific code with no clean
// testing strategy
// for more info see https://github.com/rust-lang/rust/pull/37677
// For more info, see https://github.com/rust-lang/rust/pull/37677.
if handle == c::INVALID_HANDLE_VALUE {
let err = io::Error::last_os_error();
let raw_os_err = err.raw_os_error();

View file

@ -23,7 +23,7 @@ pub fn foreach_symbol_fileline<F>(frame: Frame,
where F: FnMut(&[u8], u32) -> io::Result<()>
{
// pcinfo may return an arbitrary number of file:line pairs,
// in the order of stack trace (i.e. inlined calls first).
// in the order of stack trace (i.e., inlined calls first).
// in order to avoid allocation, we stack-allocate a fixed size of entries.
const FILELINE_SIZE: usize = 32;
let mut fileline_buf = [(ptr::null(), !0); FILELINE_SIZE];

View file

@ -269,7 +269,7 @@ impl<T: 'static> LocalKey<T> {
// ptr::write(ptr, Some(value))
//
// Due to this pattern it's possible for the destructor of the value in
// `ptr` (e.g. if this is being recursively initialized) to re-access
// `ptr` (e.g., if this is being recursively initialized) to re-access
// TLS, in which case there will be a `&` and `&mut` pointer to the same
// value (an aliasing violation). To avoid setting the "I'm running a
// destructor" flag we just use `mem::replace` which should sequence the

View file

@ -93,7 +93,7 @@
//! Threads are represented via the [`Thread`] type, which you can get in one of
//! two ways:
//!
//! * By spawning a new thread, e.g. using the [`thread::spawn`][`spawn`]
//! * By spawning a new thread, e.g., using the [`thread::spawn`][`spawn`]
//! function, and calling [`thread`][`JoinHandle::thread`] on the [`JoinHandle`].
//! * By requesting the current thread, using the [`thread::current`] function.
//!
@ -124,7 +124,7 @@
//! thread, use [`Thread::name`]. A couple examples of where the name of a thread gets used:
//!
//! * If a panic occurs in a named thread, the thread name will be printed in the panic message.
//! * The thread name is provided to the OS where applicable (e.g. `pthread_setname_np` in
//! * The thread name is provided to the OS where applicable (e.g., `pthread_setname_np` in
//! unix-like platforms).
//!
//! ## Stack size
@ -422,7 +422,7 @@ impl Builder {
///
/// - ensure that [`join`][`JoinHandle::join`] is called before any referenced
/// data is dropped
/// - use only types with `'static` lifetime bounds, i.e. those with no or only
/// - use only types with `'static` lifetime bounds, i.e., those with no or only
/// `'static` references (both [`thread::Builder::spawn`][`Builder::spawn`]
/// and [`thread::spawn`][`spawn`] enforce this property statically)
///
@ -692,7 +692,7 @@ pub fn yield_now() {
/// already poison themselves when a thread panics while holding the lock.
///
/// This can also be used in multithreaded applications, in order to send a
/// message to other threads warning that a thread has panicked (e.g. for
/// message to other threads warning that a thread has panicked (e.g., for
/// monitoring purposes).
///
/// # Examples
@ -1078,7 +1078,7 @@ struct Inner {
/// Threads are represented via the `Thread` type, which you can get in one of
/// two ways:
///
/// * By spawning a new thread, e.g. using the [`thread::spawn`][`spawn`]
/// * By spawning a new thread, e.g., using the [`thread::spawn`][`spawn`]
/// function, and calling [`thread`][`JoinHandle::thread`] on the
/// [`JoinHandle`].
/// * By requesting the current thread, using the [`thread::current`] function.

View file

@ -330,7 +330,7 @@ impl SystemTime {
/// Returns the amount of time elapsed since this system time was created.
///
/// This function may fail as the underlying system clock is susceptible to
/// drift and updates (e.g. the system clock could go backwards), so this
/// drift and updates (e.g., the system clock could go backwards), so this
/// function may not always succeed. If successful, [`Ok`]`(`[`Duration`]`)` is
/// returned where the duration represents the amount of time elapsed from
/// this time measurement to the current time.