Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #38015

Merged
merged 17 commits into from
Nov 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down Expand Up @@ -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
//!
Expand Down Expand Up @@ -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]);
/// ```
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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"
/// }
/// }
///
Expand Down
84 changes: 84 additions & 0 deletions src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -306,44 +323,111 @@ 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);
}

/// 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;
}

/// 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;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
14 changes: 14 additions & 0 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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> {
Expand Down