Skip to content

Rollup of 5 pull requests #40889

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

Merged
merged 26 commits into from
Mar 29, 2017
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
67867c6
Update docs for std::str
tigleym Mar 20, 2017
6365272
Move str docs to proper place in file.
tigleym Mar 20, 2017
f628117
Fix Rust linting error
tigleym Mar 21, 2017
dae66e0
Specialize Vec::from_iter for vec::IntoIter
sfackler Mar 18, 2017
8a91e4d
Document Cursor::new position is 0
stepancheg Mar 24, 2017
169facf
added missing links in std::net TCP docs
chordowl Mar 25, 2017
76d08ed
Update std::net:Incoming's docs to use standard iterator boilerplate
chordowl Mar 26, 2017
0df7398
std::net docs: changed occurences of "RFC" to say "IETF RFC"
chordowl Mar 25, 2017
df5830a
Added links throughout std::net::ToSocketAddrs' documentation
chordowl Mar 25, 2017
0d5baba
Added links to std::net::AddrParseError's documentation
chordowl Mar 25, 2017
347b709
Expanded and added links to std::net::{IpAddr,Ipv4Addr,Ipv6Addr} docs
chordowl Mar 26, 2017
be713fa
Removed link in std::net::ToSocketAddr's summary sentence
chordowl Mar 26, 2017
6f0c742
Expanded and added links to std::net::{SocketAddr,SocketAddrV4,Socket…
chordowl Mar 26, 2017
1a9c8ba
Added examples to std::net::{SocketAddr, SocketAddrV4, SocketAddrV6} …
chordowl Mar 26, 2017
ad816f8
Added links to std::net::Shutdown docs and made them more consistent
chordowl Mar 26, 2017
597bcec
Expanded top-level docs for std::net{TcpListener,TcpStream,UdpSocket}
chordowl Mar 26, 2017
577677d
Expanded std::net module docs
chordowl Mar 26, 2017
c2601fd
fix trailing whitespace
chordowl Mar 26, 2017
b8cbc5d
Addressed requested changes for PR #40838
chordowl Mar 27, 2017
434e601
Update various book modules
steveklabnik Mar 27, 2017
da74e86
Review request changes
tigleym Mar 27, 2017
378d230
Rollup merge of #40682 - TigleyM:str_doc, r=steveklabnik
frewsxcv Mar 29, 2017
8ae1d44
Rollup merge of #40731 - sfackler:vec-from-iter-spec, r=aturon
frewsxcv Mar 29, 2017
88badb9
Rollup merge of #40783 - stepancheg:cursor-new-0, r=aturon
frewsxcv Mar 29, 2017
2c59e03
Rollup merge of #40838 - lukaramu:std-net-docs, r=GuillaumeGomez
frewsxcv Mar 29, 2017
1214b16
Rollup merge of #40864 - steveklabnik:update-submodules, r=nrc
frewsxcv Mar 29, 2017
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/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/reference
21 changes: 20 additions & 1 deletion src/libcollections/str.rs
Original file line number Diff line number Diff line change
@@ -10,9 +10,28 @@

//! Unicode string slices.
//!
//! The `&str` type is one of the two main string types, the other being `String`.
//! Unlike its `String` counterpart, its contents are borrowed.
//!
//! # Basic Usage
//!
//! A basic string declaration of `&str` type:
//!
//! ```
//! let hello_world = "Hello, World!";
//! ```
//!
//! Here we have declared a string literal, also known as a string slice.
//! String literals have a static lifetime, which means the string `hello_world`
//! is guaranteed to be valid for the duration of the entire program.
//! We can explicitly specify `hello_world`'s lifetime as well:
//!
//! ```
//! let hello_world: &'static str = "Hello, world!";
//! ```
//!
//! *[See also the `str` primitive type](../../std/primitive.str.html).*


#![stable(feature = "rust1", since = "1.0.0")]

// Many of the usings in this module are only used in the test configuration.
29 changes: 25 additions & 4 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
@@ -1563,7 +1563,7 @@ impl<T> ops::DerefMut for Vec<T> {
impl<T> FromIterator<T> for Vec<T> {
#[inline]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Vec<T> {
<Self as SpecExtend<_, _>>::from_iter(iter.into_iter())
<Self as SpecExtend<T, I::IntoIter>>::from_iter(iter.into_iter())
}
}

@@ -1631,7 +1631,7 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
impl<T> Extend<T> for Vec<T> {
#[inline]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
self.spec_extend(iter.into_iter())
<Self as SpecExtend<T, I::IntoIter>>::spec_extend(self, iter.into_iter())
}
}

@@ -1662,7 +1662,7 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
vector
}
};
vector.spec_extend(iterator);
<Vec<T> as SpecExtend<T, I>>::spec_extend(&mut vector, iterator);
vector
}

@@ -1674,7 +1674,7 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
impl<T, I> SpecExtend<T, I> for Vec<T>
where I: TrustedLen<Item=T>,
{
fn from_iter(iterator: I) -> Self {
default fn from_iter(iterator: I) -> Self {
let mut vector = Vec::new();
vector.spec_extend(iterator);
vector
@@ -1706,6 +1706,27 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
}
}

impl<T> SpecExtend<T, IntoIter<T>> for Vec<T> {
fn from_iter(iterator: IntoIter<T>) -> Self {
// A common case is passing a vector into a function which immediately
// re-collects into a vector. We can short circuit this if the IntoIter
// has not been advanced at all.
if *iterator.buf == iterator.ptr as *mut T {
unsafe {
let vec = Vec::from_raw_parts(*iterator.buf as *mut T,
iterator.len(),
iterator.cap);
mem::forget(iterator);
vec
}
} else {
let mut vector = Vec::new();
vector.spec_extend(iterator);
vector
}
}
}

impl<'a, T: 'a, I> SpecExtend<&'a T, I> for Vec<T>
where I: Iterator<Item=&'a T>,
T: Clone,
16 changes: 16 additions & 0 deletions src/libcollectionstest/vec.rs
Original file line number Diff line number Diff line change
@@ -680,3 +680,19 @@ fn test_placement_panic() {
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| { vec.place_back() <- mkpanic(); }));
assert_eq!(vec.len(), 3);
}

#[test]
fn from_into_inner() {
let vec = vec![1, 2, 3];
let ptr = vec.as_ptr();
let vec = vec.into_iter().collect::<Vec<_>>();
assert_eq!(vec, [1, 2, 3]);
assert_eq!(vec.as_ptr(), ptr);

let ptr = &vec[1] as *const _;
let mut it = vec.into_iter();
it.next().unwrap();
let vec = it.collect::<Vec<_>>();
assert_eq!(vec, [2, 3]);
assert!(ptr != vec.as_ptr());
}
4 changes: 4 additions & 0 deletions src/libstd/io/cursor.rs
Original file line number Diff line number Diff line change
@@ -89,6 +89,10 @@ pub struct Cursor<T> {
impl<T> Cursor<T> {
/// Creates a new cursor wrapping the provided underlying I/O object.
///
/// Cursor initial position is `0` even if underlying object (e.
/// g. `Vec`) is not empty. So writing to cursor starts with
/// overwriting `Vec` content, not with appending to it.
///
/// # Examples
///
/// ```
Loading