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 9 pull requests #38450

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9976f5f
Add missing doc examples for SocketAddr struct
GuillaumeGomez Dec 8, 2016
7fe17f9
Add doc examples for UnixStream
GuillaumeGomez Dec 8, 2016
c35b9f6
Add UnixListener doc examples
GuillaumeGomez Dec 8, 2016
a78a33c
Add Incoming doc examples
GuillaumeGomez Dec 8, 2016
8323185
minor fix about visibility in reference
liigo Dec 7, 2016
e095c71
Associated items and variants inherit visibility from their traits an…
liigo Dec 13, 2016
16d4b7b
doc: Explain meaning of Result iters and link to factory functions.
sourcefrog Dec 3, 2016
60fbe7a
Add missing Duration examples
GuillaumeGomez Dec 13, 2016
8cd3081
rustdoc: a formatting nit
tshepang Dec 15, 2016
2938e6a
Add missing doc examples for UnixDatagram
GuillaumeGomez Dec 8, 2016
0971cb1
Document platform-specific differences for `std::process::exit`.
frewsxcv Dec 15, 2016
d409fc3
Rewrite, improve documentation for `core::hash::BuildHasherDefault`.
frewsxcv Dec 13, 2016
ca37604
tidy features: use 2-parameter form of internal try macro for open err
zackmdavis Dec 17, 2016
1e7bc90
stage0.txt: typo fix
est31 Dec 18, 2016
5f3b2c7
Rollup merge of #38158 - sourcefrog:doc-iter, r=GuillaumeGomez
GuillaumeGomez Dec 18, 2016
d808ae1
Rollup merge of #38215 - liigo:patch-12, r=petrochenkov
GuillaumeGomez Dec 18, 2016
1b90f83
Rollup merge of #38236 - GuillaumeGomez:unix_socket_doc, r=frewsxcv
GuillaumeGomez Dec 18, 2016
ca8f287
Rollup merge of #38334 - frewsxcv:BuildHasherDefault, r=GuillaumeGomez
GuillaumeGomez Dec 18, 2016
6f1a3c0
Rollup merge of #38346 - GuillaumeGomez:duration_doc, r=frewsxcv
GuillaumeGomez Dec 18, 2016
1fbcb3e
Rollup merge of #38395 - tshepang:nit, r=steveklabnik
GuillaumeGomez Dec 18, 2016
fdc9150
Rollup merge of #38397 - frewsxcv:platform-specific-process-exit, r=a…
GuillaumeGomez Dec 18, 2016
dae4eaa
Rollup merge of #38422 - zackmdavis:enjoy_tidy_path_error_macro_nicet…
GuillaumeGomez Dec 18, 2016
3e02adc
Rollup merge of #38445 - est31:master, r=apasel422
GuillaumeGomez Dec 18, 2016
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
3 changes: 2 additions & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,8 @@ of an item to see whether it should be allowed or not. This is where privacy
warnings are generated, or otherwise "you used a private item of another module
and weren't allowed to."

By default, everything in Rust is *private*, with one exception. Enum variants
By default, everything in Rust is *private*, with two exceptions: Associated
items in a `pub` Trait are public by default; Enum variants
in a `pub` enum are also public by default. When an item is declared as `pub`,
it can be thought of as being accessible to the outside world. For example:

Expand Down
40 changes: 37 additions & 3 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,44 @@ pub trait BuildHasher {
fn build_hasher(&self) -> Self::Hasher;
}

/// A structure which implements `BuildHasher` for all `Hasher` types which also
/// implement `Default`.
/// The `BuildHasherDefault` structure is used in scenarios where one has a
/// type that implements [`Hasher`] and [`Default`], but needs that type to
/// implement [`BuildHasher`].
///
/// This struct is 0-sized and does not need construction.
/// This structure is zero-sized and does not need construction.
///
/// # Examples
///
/// Using `BuildHasherDefault` to specify a custom [`BuildHasher`] for
/// [`HashMap`]:
///
/// ```
/// use std::collections::HashMap;
/// use std::hash::{BuildHasherDefault, Hasher};
///
/// #[derive(Default)]
/// struct MyHasher;
///
/// impl Hasher for MyHasher {
/// fn write(&mut self, bytes: &[u8]) {
/// // Your hashing algorithm goes here!
/// unimplemented!()
/// }
///
/// fn finish(&self) -> u64 {
/// // Your hashing algorithm goes here!
/// unimplemented!()
/// }
/// }
///
/// type MyBuildHasher = BuildHasherDefault<MyHasher>;
///
/// let hash_map = HashMap::<u32, u32, MyBuildHasher>::default();
/// ```
///
/// [`BuildHasher`]: trait.BuildHasher.html
/// [`Default`]: ../default/trait.Default.html
/// [`Hasher`]: trait.Hasher.html
#[stable(since = "1.7.0", feature = "build_hasher")]
pub struct BuildHasherDefault<H>(marker::PhantomData<H>);

Expand Down
29 changes: 26 additions & 3 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ impl<T, E> Result<T, E> {

/// Returns an iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
///
/// # Examples
///
/// Basic usage:
Expand All @@ -512,6 +514,8 @@ impl<T, E> Result<T, E> {
/// let x: Result<u32, &str> = Err("nothing!");
/// assert_eq!(x.iter().next(), None);
/// ```
///
/// [`Ok`]: enum.Result.html#variant.Ok
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<T> {
Expand All @@ -520,6 +524,8 @@ impl<T, E> Result<T, E> {

/// Returns a mutable iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
///
/// # Examples
///
/// Basic usage:
Expand All @@ -535,6 +541,8 @@ impl<T, E> Result<T, E> {
/// let mut x: Result<u32, &str> = Err("nothing!");
/// assert_eq!(x.iter_mut().next(), None);
/// ```
///
/// [`Ok`]: enum.Result.html#variant.Ok
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter_mut(&mut self) -> IterMut<T> {
Expand Down Expand Up @@ -848,6 +856,8 @@ impl<T, E> IntoIterator for Result<T, E> {

/// Returns a consuming iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
///
/// # Examples
///
/// Basic usage:
Expand All @@ -861,6 +871,8 @@ impl<T, E> IntoIterator for Result<T, E> {
/// let v: Vec<u32> = x.into_iter().collect();
/// assert_eq!(v, []);
/// ```
///
/// [`Ok`]: enum.Result.html#variant.Ok
#[inline]
fn into_iter(self) -> IntoIter<T> {
IntoIter { inner: self.ok() }
Expand Down Expand Up @@ -893,8 +905,13 @@ impl<'a, T, E> IntoIterator for &'a mut Result<T, E> {

/// An iterator over a reference to the [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
///
/// Created by [`Result::iter`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Result`]: enum.Result.html
/// [`Result::iter`]: enum.Result.html#method.iter
#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, T: 'a> { inner: Option<&'a T> }
Expand Down Expand Up @@ -934,8 +951,11 @@ impl<'a, T> Clone for Iter<'a, T> {

/// An iterator over a mutable reference to the [`Ok`] variant of a [`Result`].
///
/// Created by [`Result::iter_mut`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Result`]: enum.Result.html
/// [`Result::iter_mut`]: enum.Result.html#method.iter_mut
#[derive(Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IterMut<'a, T: 'a> { inner: Option<&'a mut T> }
Expand Down Expand Up @@ -968,9 +988,12 @@ impl<'a, T> FusedIterator for IterMut<'a, T> {}
#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {}

/// An iterator over the value in a [`Ok`] variant of a [`Result`]. This struct is
/// created by the [`into_iter`] method on [`Result`][`Result`] (provided by
/// the [`IntoIterator`] trait).
/// An iterator over the value in a [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
///
/// This struct is created by the [`into_iter`] method on
/// [`Result`][`Result`] (provided by the [`IntoIterator`] trait).
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Result`]: enum.Result.html
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ pub fn main_args(args: &[String]) -> isize {
}

let external_html = match ExternalHtml::load(
&matches.opt_strs("html-in-header"), &matches.opt_strs("html-before-content"),
&matches.opt_strs("html-in-header"),
&matches.opt_strs("html-before-content"),
&matches.opt_strs("html-after-content")) {
Some(eh) => eh,
None => return 3
None => return 3,
};
let crate_name = matches.opt_str("crate-name");
let playground_url = matches.opt_str("playground-url");
Expand Down
17 changes: 17 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,30 @@ impl Child {
/// this function at a known point where there are no more destructors left
/// to run.
///
/// ## Platform-specific behavior
///
/// **Unix**: On Unix-like platforms, it is unlikely that all 32 bits of `exit`
/// will be visible to a parent process inspecting the exit code. On most
/// Unix-like platforms, only the eight least-significant bits are considered.
///
/// # Examples
///
/// ```
/// use std::process;
///
/// process::exit(0);
/// ```
///
/// Due to [platform-specific behavior], the exit code for this example will be
/// `0` on Linux, but `256` on Windows:
///
/// ```
/// use std::process;
///
/// process::exit(0x0f00);
/// ```
///
/// [platform-specific behavior]: #platform-specific-behavior
#[stable(feature = "rust1", since = "1.0.0")]
pub fn exit(code: i32) -> ! {
::sys_common::cleanup();
Expand Down
Loading