about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-24 22:58:28 +0000
committerbors <bors@rust-lang.org>2016-02-24 22:58:28 +0000
commitf6f050d09003a4c7895f44fed3a7c6cdce8f2949 (patch)
treeb86509358be85838e2c677348bb476a981327f6b /src/libstd
parent0ef8d426050318934d16d962325ec002eaf0c29d (diff)
parentb660ca59ff16bc4bfb675fa6afe61b32aa284d96 (diff)
downloadrust-f6f050d09003a4c7895f44fed3a7c6cdce8f2949.tar.gz
rust-f6f050d09003a4c7895f44fed3a7c6cdce8f2949.zip
Auto merge of #31873 - Manishearth:rollup, r=Manishearth
- Successful merges: #31677, #31784, #31839, #31842, #31843, #31850, #31863, #31868, #31870
- Failed merges:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/net/addr.rs5
-rw-r--r--src/libstd/net/parser.rs5
-rw-r--r--src/libstd/primitive_docs.rs45
-rw-r--r--src/libstd/sys/windows/thread_local.rs5
4 files changed, 50 insertions, 10 deletions
diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs
index 6ce6777d11e..78da9412212 100644
--- a/src/libstd/net/addr.rs
+++ b/src/libstd/net/addr.rs
@@ -467,9 +467,8 @@ impl ToSocketAddrs for str {
     type Iter = vec::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
         // try to parse as a regular SocketAddr first
-        match self.parse().ok() {
-            Some(addr) => return Ok(vec![addr].into_iter()),
-            None => {}
+        if let Some(addr) = self.parse().ok() {
+            return Ok(vec![addr].into_iter());
         }
 
         macro_rules! try_opt {
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs
index 46a0309dbb5..63eee6bcfde 100644
--- a/src/libstd/net/parser.rs
+++ b/src/libstd/net/parser.rs
@@ -66,9 +66,8 @@ impl<'a> Parser<'a> {
     fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T> + 'static>])
                -> Option<T> {
         for pf in parsers {
-            match self.read_atomically(|p: &mut Parser| pf(p)) {
-                Some(r) => return Some(r),
-                None => {}
+            if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) {
+                return Some(r);
             }
         }
         None
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index b840e51873e..e5819522123 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -12,6 +12,50 @@
 //
 /// The boolean type.
 ///
+/// The `bool` represents a value, which could only be either `true` or `false`.
+///
+/// # Basic usage
+///
+/// `bool` implements various traits, such as [`BitAnd`], [`BitOr`], [`Not`], etc.,
+/// which allow us to perform boolean operations using `&`, `|` and `!`.
+///
+/// [`if`] always demands a `bool` value. [`assert!`], being an important macro in testing,
+/// checks whether an expression returns `true`.
+///
+/// ```
+/// let bool_val = true & false | false;
+/// assert!(!bool_val);
+/// ```
+///
+/// [`assert!`]: std/macro.assert!.html
+/// [`if` conditionals]: ../../book/if.html
+/// [`BitAnd`]: ../ops/trait.BitAnd.html
+/// [`BitOr`]: ../ops/trait.BitOr.html
+/// [`Not`]: ../ops/trait.Not.html
+///
+/// # Examples
+///
+/// A trivial example of the usage of `bool`,
+///
+/// ```
+/// let praise_the_borrow_checker = true;
+///
+/// // using the `if` conditional
+/// if praise_the_borrow_checker {
+///     println!("oh, yeah!");
+/// } else {
+///     println!("what?!!");
+/// }
+///
+/// // ... or, a match pattern
+/// match praise_the_borrow_checker {
+///     true => println!("keep praising!"),
+///     false => println!("you should praise!"),
+/// }
+/// ```
+///
+/// Also, since `bool` implements the [`Copy`](../marker/trait.Copy.html) trait, we don't
+/// have to worry about the move semantics (just like the integer and float primitives).
 mod prim_bool { }
 
 #[doc(primitive = "char")]
@@ -533,4 +577,3 @@ mod prim_isize { }
 /// *[See also the `std::usize` module](usize/index.html).*
 ///
 mod prim_usize { }
-
diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs
index 6a5c38ed9d0..59da74b7287 100644
--- a/src/libstd/sys/windows/thread_local.rs
+++ b/src/libstd/sys/windows/thread_local.rs
@@ -69,9 +69,8 @@ static mut DTORS: *mut Vec<(Key, Dtor)> = ptr::null_mut();
 pub unsafe fn create(dtor: Option<Dtor>) -> Key {
     let key = c::TlsAlloc();
     assert!(key != c::TLS_OUT_OF_INDEXES);
-    match dtor {
-        Some(f) => register_dtor(key, f),
-        None => {}
+    if let Some(f) = dtor {
+        register_dtor(key, f);
     }
     return key;
 }