Auto merge of #38015 - sanxiyn:rollup, r=sanxiyn

Rollup of 7 pull requests

- Successful merges: #37962, #37963, #37967, #37978, #37985, #38001, #38010
- Failed merges:
This commit is contained in:
bors 2016-11-26 07:40:43 -06:00 committed by GitHub
commit 7e39c0ede5
8 changed files with 119 additions and 14 deletions

View File

@ -16,7 +16,7 @@
#![unstable(feature = "enumset",
reason = "matches collection reform specification, \
waiting for dust to settle",
issue = "0")]
issue = "37966")]
use core::marker;
use core::fmt;

View File

@ -225,12 +225,12 @@
//! often called 'iterator adapters', as they're a form of the 'adapter
//! pattern'.
//!
//! Common iterator adapters include [`map()`], [`take()`], and [`collect()`].
//! Common iterator adapters include [`map()`], [`take()`], and [`filter()`].
//! For more, see their documentation.
//!
//! [`map()`]: trait.Iterator.html#method.map
//! [`take()`]: trait.Iterator.html#method.take
//! [`collect()`]: trait.Iterator.html#method.collect
//! [`filter()`]: trait.Iterator.html#method.filter
//!
//! # Laziness
//!
@ -268,7 +268,7 @@
//! [`map()`]: trait.Iterator.html#method.map
//!
//! The two most common ways to evaluate an iterator are to use a `for` loop
//! like this, or using the [`collect()`] adapter to produce a new collection.
//! like this, or using the [`collect()`] method to produce a new collection.
//!
//! [`collect()`]: trait.Iterator.html#method.collect
//!
@ -937,7 +937,7 @@ unsafe impl<A, B> TrustedLen for Zip<A, B>
/// you can also [`map()`] backwards:
///
/// ```rust
/// let v: Vec<i32> = vec![1, 2, 3].into_iter().rev().map(|x| x + 1).collect();
/// let v: Vec<i32> = vec![1, 2, 3].into_iter().map(|x| x + 1).rev().collect();
///
/// assert_eq!(v, [4, 3, 2]);
/// ```

View File

@ -109,7 +109,7 @@ pub trait Error: Debug + Display {
///
/// impl Error for SuperError {
/// fn description(&self) -> &str {
/// "I'm the superhero of errors!"
/// "I'm the superhero of errors"
/// }
///
/// fn cause(&self) -> Option<&Error> {
@ -128,7 +128,7 @@ pub trait Error: Debug + Display {
///
/// impl Error for SuperErrorSideKick {
/// fn description(&self) -> &str {
/// "I'm SuperError side kick!"
/// "I'm SuperError side kick"
/// }
/// }
///

View File

@ -282,6 +282,14 @@ impl SocketAddrV4 {
impl SocketAddrV6 {
/// Creates a new socket address from the ip/port/flowinfo/scope_id
/// components.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32)
-> SocketAddrV6 {
@ -298,6 +306,15 @@ impl SocketAddrV6 {
}
/// Returns the IP address associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn ip(&self) -> &Ipv6Addr {
unsafe {
@ -306,18 +323,47 @@ impl SocketAddrV6 {
}
/// Change the IP address associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
/// socket.set_ip(Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
/// assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
/// ```
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
pub fn set_ip(&mut self, new_ip: Ipv6Addr) {
self.inner.sin6_addr = *new_ip.as_inner()
}
/// Returns the port number associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
/// assert_eq!(socket.port(), 8080);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn port(&self) -> u16 {
ntoh(self.inner.sin6_port)
}
/// Change the port number associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
/// socket.set_port(4242);
/// assert_eq!(socket.port(), 4242);
/// ```
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
pub fn set_port(&mut self, new_port: u16) {
self.inner.sin6_port = hton(new_port);
@ -325,12 +371,31 @@ impl SocketAddrV6 {
/// Returns the flow information associated with this address,
/// corresponding to the `sin6_flowinfo` field in C.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
/// assert_eq!(socket.flowinfo(), 10);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn flowinfo(&self) -> u32 {
self.inner.sin6_flowinfo
}
/// Change the flow information associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
/// socket.set_flowinfo(56);
/// assert_eq!(socket.flowinfo(), 56);
/// ```
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
pub fn set_flowinfo(&mut self, new_flowinfo: u32) {
self.inner.sin6_flowinfo = new_flowinfo;
@ -338,12 +403,31 @@ impl SocketAddrV6 {
/// Returns the scope ID associated with this address,
/// corresponding to the `sin6_scope_id` field in C.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
/// assert_eq!(socket.scope_id(), 78);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn scope_id(&self) -> u32 {
self.inner.sin6_scope_id
}
/// Change the scope ID associated with this socket address.
///
/// # Examples
///
/// ```
/// use std::net::{SocketAddrV6, Ipv6Addr};
///
/// let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
/// socket.set_scope_id(42);
/// assert_eq!(socket.scope_id(), 42);
/// ```
#[stable(feature = "sockaddr_setters", since = "1.9.0")]
pub fn set_scope_id(&mut self, new_scope_id: u32) {
self.inner.sin6_scope_id = new_scope_id;

View File

@ -153,7 +153,7 @@ pub fn take_hook() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> {
match hook {
Hook::Default => Box::new(default_hook),
Hook::Custom(ptr) => {Box::from_raw(ptr)} // FIXME #30530
Hook::Custom(ptr) => Box::from_raw(ptr),
}
}
}

View File

@ -491,11 +491,11 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
/// becomes available. These channels differ greatly in the semantics of the
/// sender from asynchronous channels, however.
///
/// This channel has an internal buffer on which messages will be queued. When
/// the internal buffer becomes full, future sends will *block* waiting for the
/// buffer to open up. Note that a buffer size of 0 is valid, in which case this
/// becomes "rendezvous channel" where each send will not return until a recv
/// is paired with it.
/// This channel has an internal buffer on which messages will be queued. `bound`
/// specifies the buffer size. When the internal buffer becomes full, future sends
/// will *block* waiting for the buffer to open up. Note that a buffer size of 0
/// is valid, in which case this becomes "rendezvous channel" where each send will
/// not return until a recv is paired with it.
///
/// As with asynchronous channels, all senders will panic in `send` if the
/// `Receiver` has been destroyed.

View File

@ -133,7 +133,14 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
/// dropped (falls out of scope), the lock will be unlocked.
///
/// The data protected by the mutex can be access through this guard via its
/// `Deref` and `DerefMut` implementations
/// `Deref` and `DerefMut` implementations.
///
/// This structure is created by the [`lock()`] and [`try_lock()`] methods on
/// [`Mutex`].
///
/// [`lock()`]: struct.Mutex.html#method.lock
/// [`try_lock()`]: struct.Mutex.html#method.try_lock
/// [`Mutex`]: struct.Mutex.html
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> {

View File

@ -77,6 +77,13 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
/// RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read()`] and [`try_read()`] methods on
/// [`RwLock`].
///
/// [`read()`]: struct.RwLock.html#method.read
/// [`try_read()`]: struct.RwLock.html#method.try_read
/// [`RwLock`]: struct.RwLock.html
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
@ -88,6 +95,13 @@ impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
/// RAII structure used to release the exclusive write access of a lock when
/// dropped.
///
/// This structure is created by the [`write()`] and [`try_write()`] methods
/// on [`RwLock`].
///
/// [`write()`]: struct.RwLock.html#method.write
/// [`try_write()`]: struct.RwLock.html#method.try_write
/// [`RwLock`]: struct.RwLock.html
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {