diff options
| author | bors <bors@rust-lang.org> | 2017-11-20 22:35:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-20 22:35:41 +0000 |
| commit | 1e44fee88d48e9f7844c6d316ae8540db19dc9fa (patch) | |
| tree | 9172d777e1fb0167b82154a5391cf53ed9cac16c /src/libstd | |
| parent | 33374fa9d09e2a790979b31e61100dfed4b44139 (diff) | |
| parent | 079a6e4cc2ade85faf8c7a4be1bbbd60c7aee9c1 (diff) | |
| download | rust-1e44fee88d48e9f7844c6d316ae8540db19dc9fa.tar.gz rust-1e44fee88d48e9f7844c6d316ae8540db19dc9fa.zip | |
Auto merge of #46130 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #46082, #46088, #46092, #46107, #46119, #46121, #46122, #46124, #46128 - Failed merges:
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/f32.rs | 5 | ||||
| -rw-r--r-- | src/libstd/f64.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 34 | ||||
| -rw-r--r-- | src/libstd/panic.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync/mutex.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/redox/os.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/process.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 4 |
9 files changed, 70 insertions, 12 deletions
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 14f0edc3690..645a4c21150 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -9,8 +9,9 @@ // except according to those terms. //! This module provides constants which are specific to the implementation -//! of the `f32` floating point data type. Mathematically significant -//! numbers are provided in the `consts` sub-module. +//! of the `f32` floating point data type. +//! +//! Mathematically significant numbers are provided in the `consts` sub-module. //! //! *[See also the `f32` primitive type](../primitive.f32.html).* diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index e0f0acc6ac4..7fd798155bd 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -9,8 +9,9 @@ // except according to those terms. //! This module provides constants which are specific to the implementation -//! of the `f64` floating point data type. Mathematically significant -//! numbers are provided in the `consts` sub-module. +//! of the `f64` floating point data type. +//! +//! Mathematically significant numbers are provided in the `consts` sub-module. //! //! *[See also the `f64` primitive type](../primitive.f64.html).* diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 57f8c39756e..62313d7d3a6 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -419,14 +419,8 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> /// /// [`File`]s implement `Read`: /// -/// [`read()`]: trait.Read.html#tymethod.read -/// [`std::io`]: ../../std/io/index.html -/// [`File`]: ../fs/struct.File.html -/// [`BufRead`]: trait.BufRead.html -/// [`BufReader`]: struct.BufReader.html -/// /// ``` -/// use std::io; +/// # use std::io; /// use std::io::prelude::*; /// use std::fs::File; /// @@ -449,6 +443,32 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> /// # Ok(()) /// # } /// ``` +/// +/// Read from `&str` because [`&[u8]`] implements [`Read`]: +/// +/// ``` +/// # use std::io; +/// use std::io::prelude::*; +/// +/// # fn foo() -> io::Result<()> { +/// let mut b = "This string will be read".as_bytes(); +/// let mut buffer = [0; 10]; +/// +/// // read up to 10 bytes +/// b.read(&mut buffer)?; +/// +/// // etc... it works exactly as a File does! +/// # Ok(()) +/// # } +/// ``` +/// +/// [`read()`]: trait.Read.html#tymethod.read +/// [`std::io`]: ../../std/io/index.html +/// [`File`]: ../fs/struct.File.html +/// [`BufRead`]: trait.BufRead.html +/// [`BufReader`]: struct.BufReader.html +/// [`&[u8]`]: primitive.slice.html +/// #[stable(feature = "rust1", since = "1.0.0")] pub trait Read { /// Pull some bytes from this source into the specified buffer, returning diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 385076e50dd..219e55d6c12 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Panic support in the standard library +//! Panic support in the standard library. #![stable(feature = "std_panic", since = "1.9.0")] diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index eb507858b92..81f5594bc52 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> { } } +#[stable(feature = "mutex_from", since = "1.22.0")] +impl<T> From<T> for Mutex<T> { + /// Creates a new mutex in an unlocked state ready for use. + /// This is equivalent to [`Mutex::new`]. + /// + /// [`Mutex::new`]: #method.new + fn from(t: T) -> Self { + Mutex::new(t) + } +} + #[stable(feature = "mutex_default", since = "1.10.0")] impl<T: ?Sized + Default> Default for Mutex<T> { /// Creates a `Mutex<T>`, with the `Default` value for T. diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 6216d78528d..fd6cff6b69c 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> { } } +#[stable(feature = "rw_lock_from", since = "1.22.0")] +impl<T> From<T> for RwLock<T> { + /// Creates a new instance of an `RwLock<T>` which is unlocked. + /// This is equivalent to [`RwLock::new`]. + /// + /// [`RwLock::new`]: #method.new + fn from(t: T) -> Self { + RwLock::new(t) + } +} + impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockReadGuard<'rwlock, T>> { diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index c27e2ee172c..480765b77a0 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -213,3 +213,7 @@ pub fn exit(code: i32) -> ! { pub fn getpid() -> u32 { syscall::getpid().unwrap() as u32 } + +pub fn getppid() -> u32 { + syscall::getppid().unwrap() as u32 +} diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index cde21b089a2..60309bec6d4 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -191,3 +191,9 @@ impl IntoRawFd for process::ChildStderr { self.into_inner().into_fd().into_raw() } } + +/// Returns the OS-assigned process identifier associated with this process's parent. +#[unstable(feature = "unix_ppid", issue = "46104")] +pub fn parent_id() -> u32 { + ::sys::os::getppid() +} diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 40b73f1b307..7e965b4b4c5 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -515,3 +515,7 @@ pub fn exit(code: i32) -> ! { pub fn getpid() -> u32 { unsafe { libc::getpid() as u32 } } + +pub fn getppid() -> u32 { + unsafe { libc::getppid() as u32 } +} |
