From 9a01a23b9c7e9edd171bb86a1e27945cd37c9e4c Mon Sep 17 00:00:00 2001 From: Ryan O'Neill Date: Sat, 29 Jul 2023 13:20:45 -0700 Subject: [PATCH 1/2] Documentation: Fix Stilted Language in Vec->Indexing Problem Language in the Vec->Indexing documentation sounds stilted due to incorrect word ordering: "... type allows to access values by index." Solution Reorder words in the Vec->Indexing documentation to flow better: "... type allows access to values by index." The phrase "allows access to" also matches other existing documentation. --- library/alloc/src/vec/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 1b24c63755051..e45ddc7896beb 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -213,7 +213,7 @@ mod spec_extend; /// /// # Indexing /// -/// The `Vec` type allows to access values by index, because it implements the +/// The `Vec` type allows access to values by index, because it implements the /// [`Index`] trait. An example will be more explicit: /// /// ``` From d67d9890ae20492e26803d70b993ab5b03785890 Mon Sep 17 00:00:00 2001 From: yukang Date: Sat, 8 Apr 2023 00:50:06 +0800 Subject: [PATCH 2/2] Fix the example in document for WaitTimeoutResult::timed_out --- library/std/src/sync/condvar.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/library/std/src/sync/condvar.rs b/library/std/src/sync/condvar.rs index 76a1b4a2a86cd..9c4b926b7ecdc 100644 --- a/library/std/src/sync/condvar.rs +++ b/library/std/src/sync/condvar.rs @@ -21,11 +21,11 @@ impl WaitTimeoutResult { /// /// # Examples /// - /// This example spawns a thread which will update the boolean value and - /// then wait 100 milliseconds before notifying the condvar. + /// This example spawns a thread which will sleep 20 milliseconds before + /// updating a boolean value and then notifying the condvar. /// - /// The main thread will wait with a timeout on the condvar and then leave - /// once the boolean has been updated and notified. + /// The main thread will wait with a 10 millisecond timeout on the condvar + /// and will leave the loop upon timeout. /// /// ``` /// use std::sync::{Arc, Condvar, Mutex}; @@ -49,14 +49,12 @@ impl WaitTimeoutResult { /// /// // Wait for the thread to start up. /// let (lock, cvar) = &*pair; - /// let mut started = lock.lock().unwrap(); /// loop { /// // Let's put a timeout on the condvar's wait. - /// let result = cvar.wait_timeout(started, Duration::from_millis(10)).unwrap(); - /// // 10 milliseconds have passed, or maybe the value changed! - /// started = result.0; - /// if *started == true { - /// // We received the notification and the value has been updated, we can leave. + /// let result = cvar.wait_timeout(lock.lock().unwrap(), Duration::from_millis(10)).unwrap(); + /// // 10 milliseconds have passed. + /// if result.1.timed_out() { + /// // timed out now and we can leave. /// break /// } /// }