提交 306035c2 编写于 作者: B bors

Auto merge of #39933 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 5 pull requests

- Successful merges: #39847, #39862, #39898, #39904, #39928
- Failed merges:
......@@ -169,7 +169,7 @@ So this is where quotes comes in. The `ast` argument is a struct that gives us
a representation of our type (which can be either a `struct` or an `enum`).
Check out the [docs](https://docs.rs/syn/0.10.5/syn/struct.MacroInput.html),
there is some useful information there. We are able to get the name of the
type using `ast.ident`. The `quote!` macro let's us write up the Rust code
type using `ast.ident`. The `quote!` macro lets us write up the Rust code
that we wish to return and convert it into `Tokens`. `quote!` let's us use some
really cool templating mechanics; we simply write `#name` and `quote!` will
replace it with the variable named `name`. You can even do some repetition
......
......@@ -1250,17 +1250,17 @@ pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Divide one string into two at an index.
/// Splits the string into two at the given index.
///
/// The argument, `mid`, should be a byte offset from the start of the string. It must also
/// be on the boundary of a UTF-8 code point.
/// Returns a newly allocated `String`. `self` contains bytes `[0, at)`, and
/// the returned `String` contains bytes `[at, len)`. `at` must be on the
/// boundary of a UTF-8 code point.
///
/// The two strings returned go from the start of the string to `mid`, and from `mid` to the end
/// of the string.
/// Note that the capacity of `self` does not change.
///
/// # Panics
///
/// Panics if `mid` is not on a `UTF-8` code point boundary, or if it is beyond the last
/// Panics if `at` is not on a `UTF-8` code point boundary, or if it is beyond the last
/// code point of the string.
///
/// # Examples
......@@ -1275,9 +1275,9 @@ pub fn is_empty(&self) -> bool {
/// ```
#[inline]
#[stable(feature = "string_split_off", since = "1.16.0")]
pub fn split_off(&mut self, mid: usize) -> String {
assert!(self.is_char_boundary(mid));
let other = self.vec.split_off(mid);
pub fn split_off(&mut self, at: usize) -> String {
assert!(self.is_char_boundary(at));
let other = self.vec.split_off(at);
unsafe { String::from_utf8_unchecked(other) }
}
......
......@@ -1603,12 +1603,12 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
let mut i = self.len();
while let Some(v) = self.next_back() {
if predicate(v) {
return Some(i - 1);
}
// No need for an overflow check here, because `ExactSizeIterator`
// implies that the number of elements fits into a `usize`.
i -= 1;
if predicate(v) {
return Some(i);
}
}
None
}
......
......@@ -96,7 +96,9 @@ pub struct VarsOs { inner: os_imp::Env }
///
/// While iterating, the returned iterator will panic if any key or value in the
/// environment is not valid unicode. If this is not desired, consider using the
/// `env::vars_os` function.
/// [`env::vars_os`] function.
///
/// [`env::vars_os`]: fn.vars_os.html
///
/// # Examples
///
......@@ -171,9 +173,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// Fetches the environment variable `key` from the current process.
///
/// The returned result is `Ok(s)` if the environment variable is present and is
/// The returned result is [`Ok(s)`] if the environment variable is present and is
/// valid unicode. If the environment variable is not present, or it is not
/// valid unicode, then `Err` will be returned.
/// valid unicode, then [`Err`] will be returned.
///
/// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok
/// [`Err`]: ../result/enum.Result.html#variant.Err
///
/// # Examples
///
......@@ -199,7 +204,9 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
}
/// Fetches the environment variable `key` from the current process, returning
/// `None` if the variable isn't set.
/// [`None`] if the variable isn't set.
///
/// [`None`]: ../option/enum.Option.html#variant.None
///
/// # Examples
///
......
......@@ -316,7 +316,7 @@ fn call_inner(&'static self,
}
// Once we've enqueued ourselves, wait in a loop.
// Aftewards reload the state and continue with what we
// Afterwards reload the state and continue with what we
// were doing from before.
while !node.signaled.load(Ordering::SeqCst) {
thread::park();
......
......@@ -28,8 +28,8 @@
/// # Initialization and Destruction
///
/// Initialization is dynamically performed on the first call to `with()`
/// within a thread, and values support destructors which will be run when a
/// thread exits.
/// within a thread, and values that implement `Drop` get destructed when a
/// thread exits. Some caveats apply, which are explained below.
///
/// # Examples
///
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册