about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-06-04 08:42:22 +0000
committerbors <bors@rust-lang.org>2015-06-04 08:42:22 +0000
commit0aeb9f6f08c353c71d962d5cc7a231e73040ca3c (patch)
tree37ac7efa631a9ffd2a32c330b3223135d3c711fc /src/libstd
parent80d08a37b6215a59ecce042f36ad446c5357b543 (diff)
parentfd3b6ca508ed99004a11291ef1d2c64104102a41 (diff)
downloadrust-0aeb9f6f08c353c71d962d5cc7a231e73040ca3c.tar.gz
rust-0aeb9f6f08c353c71d962d5cc7a231e73040ca3c.zip
Auto merge of #26002 - Manishearth:rollup, r=Manishearth
- Successful merges: #25900, #25987, #25988, #25990, #25994, #26000
- Failed merges: 
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/macros.rs29
-rw-r--r--src/libstd/sync/rwlock.rs4
2 files changed, 32 insertions, 1 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 32193b4089d..706571b67c9 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -117,7 +117,34 @@ macro_rules! println {
 }
 
 /// Helper macro for unwrapping `Result` values while returning early with an
-/// error if the value of the expression is `Err`.
+/// error if the value of the expression is `Err`. Can only be used in
+/// functions that return `Result` because of the early return of `Err` that
+/// it provides.
+///
+/// # Examples
+///
+/// ```
+/// use std::io;
+/// use std::fs::File;
+/// use std::io::prelude::*;
+///
+/// fn write_to_file_using_try() -> Result<(), io::Error> {
+///     let mut file = try!(File::create("my_best_friends.txt"));
+///     try!(file.write_all(b"This is a list of my best friends."));
+///     println!("I wrote to the file");
+///     Ok(())
+/// }
+/// // This is equivalent to:
+/// fn write_to_file_using_match() -> Result<(), io::Error> {
+///     let mut file = try!(File::create("my_best_friends.txt"));
+///     match file.write_all(b"This is a list of my best friends.") {
+///         Ok(_) => (),
+///         Err(e) => return Err(e),
+///     }
+///     println!("I wrote to the file");
+///     Ok(())
+/// }
+/// ```
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! try {
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index e7c3d744c17..857d8889b7c 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -24,6 +24,10 @@ use sys_common::rwlock as sys;
 /// of the underlying data (exclusive access) and the read portion of this lock
 /// typically allows for read-only access (shared access).
 ///
+/// The priority policy of the lock is dependent on the underlying operating
+/// system's implementation, and this type does not guarantee that any
+/// particular policy will be used.
+///
 /// The type parameter `T` represents the data that this lock protects. It is
 /// required that `T` satisfies `Send` to be shared across threads and `Sync` to
 /// allow concurrent access through readers. The RAII guards returned from the