提交 1320c293 编写于 作者: B bors

Auto merge of #25025 - Manishearth:rollup, r=Manishearth

- Successful merges: #24979, #24980, #24981, #24982, #24983, #24987, #24988, #24991, #24992, #24994, #24998, #25002, #25010, #25014, #25020, #25021
- Failed merges: 
......@@ -1557,8 +1557,7 @@ 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
in a `pub` enum are also public by default. You are allowed to alter this
default visibility with the `priv` keyword. When an item is declared as `pub`,
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:
```
......@@ -2426,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in
parentheses. They are used to create [tuple-typed](#tuple-types) values.
```{.tuple}
(0,);
(0.0, 4.5);
("a", 4usize, true);
```
You can disambiguate a single-element tuple from a value in parentheses with a
comma:
```
(0,); // single-element tuple
(0); // zero in parentheses
```
### Unit expressions
The expression `()` denotes the _unit value_, the only value of the type with
......
......@@ -67,4 +67,4 @@ Rust attributes are used for a number of different things. There is a full list
of attributes [in the reference][reference]. Currently, you are not allowed to
create your own attributes, the Rust compiler defines them.
[reference]: reference.html#attributes
[reference]: ../reference.html#attributes
......@@ -19,9 +19,9 @@ this reason.
# `static`
Rust provides a ‘global variable’ sort of facility in static items. They’re
similar to [constants][const], but static items aren’t inlined upon use. This
means that there is only one instance for each value, and it’s at a fixed
location in memory.
similar to constants, but static items aren’t inlined upon use. This means that
there is only one instance for each value, and it’s at a fixed location in
memory.
Here’s an example:
......@@ -29,8 +29,6 @@ Here’s an example:
static N: i32 = 5;
```
[const]: const.html
Unlike [`let`][let] bindings, you must annotate the type of a `static`.
[let]: variable-bindings.html
......
......@@ -235,7 +235,7 @@ Ranges are one of two basic iterators that you'll see. The other is `iter()`.
in turn:
```rust
let nums = [1, 2, 3];
let nums = vec![1, 2, 3];
for num in nums.iter() {
println!("{}", num);
......@@ -243,18 +243,7 @@ for num in nums.iter() {
```
These two basic iterators should serve you well. There are some more
advanced iterators, including ones that are infinite. Like using range syntax
and `step_by`:
```rust
# #![feature(step_by)]
(1..).step_by(5);
```
This iterator counts up from one, adding five each time. It will give
you a new integer every time, forever (well, technically, until it reaches the
maximum number representable by an `i32`). But since iterators are lazy,
that's okay! You probably don't want to use `collect()` on it, though...
advanced iterators, including ones that are infinite.
That's enough about iterators. Iterator adapters are the last concept
we need to talk about with regards to iterators. Let's get to it!
......
......@@ -93,8 +93,7 @@ If not, there are a number of places where you can get help. The easiest is
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
(a silly nickname we call ourselves), and we can help you out. Other great
resources include [the user’s forum][users], and [Stack Overflow][stack
overflow].
resources include [the user’s forum][users], and [Stack Overflow][stack overflow].
[irc]: irc://irc.mozilla.org/#rust
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
......
......@@ -248,6 +248,14 @@ or “breaks up” the tuple, and assigns the bits to three bindings.
This pattern is very powerful, and we’ll see it repeated more later.
You can disambiguate a single-element tuple from a value in parentheses with a
comma:
```
(0,); // single-element tuple
(0); // zero in parentheses
```
## Tuple Indexing
You can also access fields of a tuple with indexing syntax:
......
......@@ -80,7 +80,7 @@ Raw pointers are useful for FFI: Rust’s `*const T` and `*mut T` are similar to
C’s `const T*` and `T*`, respectfully. For more about this use, consult the
[FFI chapter][ffi].
[ffi]: ffi.md
[ffi]: ffi.html
# References and raw pointers
......
......@@ -101,7 +101,7 @@ Rust has a feature called ‘`static mut`’ which allows for mutable global sta
Doing so can cause a data race, and as such is inherently not safe. For more
details, see the [static][static] section of the book.
[static]: static.html
[static]: const-and-static.html#static
## Dereference a raw pointer
......
......@@ -38,9 +38,11 @@ impl Foo for &str {
```
Meaning, this implementation would only work for [references][ref], and not
other types of pointers. With this `impl`, all pointers, including (at some
point, there are some bugs to fix first) user-defined custom smart pointers,
can use this `impl`.
other types of pointers. With the `impl for str`, all pointers, including (at
some point, there are some bugs to fix first) user-defined custom smart
pointers, can use this `impl`.
[ref]: references-and-borrowing.html
# ?Sized
......
......@@ -398,7 +398,7 @@
//! longer than this width, then it is truncated down to this many characters and only those are
//! emitted.
//!
//! For integral types, this has no meaning currently.
//! For integral types, this is ignored.
//!
//! For floating-point types, this indicates how many digits after the decimal point should be
//! printed.
......
......@@ -113,12 +113,14 @@ unsafe fn bswap8(x: u8) -> u8 { x }
$mul_with_overflow:path) => {
/// Returns the smallest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn min_value() -> $T {
(-1 as $T) << ($BITS - 1)
}
/// Returns the largest value that can be represented by this integer type.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn max_value() -> $T {
let min = $T::min_value(); !min
}
......
......@@ -899,7 +899,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
if let ast::MethodImplItem(ref sig, _) = ii.node {
// if the method specifies a visibility, use that, otherwise
// inherit the visibility from the impl (so `foo` in `pub impl
// { fn foo(); }` is public, but private in `priv impl { fn
// { fn foo(); }` is public, but private in `impl { fn
// foo(); }`).
let method_vis = ii.vis.inherit_from(parent_visibility);
Some((sig, ii.id, ii.ident, method_vis, ii.span))
......
......@@ -525,7 +525,7 @@ pub struct Utf16Encoder<I> {
}
impl<I> Utf16Encoder<I> {
/// Create an UTF-16 encoder from any `char` iterator.
/// Create a UTF-16 encoder from any `char` iterator.
pub fn new(chars: I) -> Utf16Encoder<I> where I: Iterator<Item=char> {
Utf16Encoder { chars: chars, extra: 0 }
}
......
......@@ -27,7 +27,7 @@
use sync::{StaticMutex, MUTEX_INIT};
use sys::os as os_imp;
/// Returns the current working directory as a `Path`.
/// Returns the current working directory as a `PathBuf`.
///
/// # Errors
///
......
......@@ -643,7 +643,7 @@ pub fn readonly(&self) -> bool { self.0.readonly() }
/// use std::fs::File;
///
/// # fn foo() -> std::io::Result<()> {
/// let mut f = try!(File::create("foo.txt"));
/// let f = try!(File::create("foo.txt"));
/// let metadata = try!(f.metadata());
/// let mut permissions = metadata.permissions();
///
......
......@@ -236,7 +236,7 @@ fn bytes(self) -> Bytes<Self> where Self: Sized {
/// Transforms this `Read` instance to an `Iterator` over `char`s.
///
/// This adaptor will attempt to interpret this reader as an UTF-8 encoded
/// This adaptor will attempt to interpret this reader as a UTF-8 encoded
/// sequence of characters. The returned iterator will return `None` once
/// EOF is reached for this reader. Otherwise each element yielded will be a
/// `Result<char, E>` where `E` may contain information about what I/O error
......
......@@ -11,7 +11,7 @@
//! Dragonfly-specific raw type definitions
use os::raw::c_long;
use os::unix::raw::{pid_t, uid_t, gid_t};
use os::unix::raw::{uid_t, gid_t};
pub type blkcnt_t = i64;
pub type blksize_t = u32;
......
......@@ -11,7 +11,7 @@
//! FreeBSD-specific raw type definitions
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t, pid_t};
use os::unix::raw::{uid_t, gid_t};
pub type blkcnt_t = i64;
pub type blksize_t = i64;
......
......@@ -11,7 +11,7 @@
//! iOS-specific raw type definitions
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t, pid_t};
use os::unix::raw::{uid_t, gid_t};
pub type blkcnt_t = i64;
pub type blksize_t = i32;
......
......@@ -11,7 +11,7 @@
//! OpenBSD-specific raw type definitions
use os::raw::c_long;
use os::unix::raw::{uid_t, gid_t, pid_t};
use os::unix::raw::{uid_t, gid_t};
pub type blkcnt_t = i64;
pub type blksize_t = u32;
......
......@@ -161,7 +161,7 @@ pub fn with_capacity(n: usize) -> Wtf8Buf {
Wtf8Buf { bytes: Vec::with_capacity(n) }
}
/// Creates a WTF-8 string from an UTF-8 `String`.
/// Creates a WTF-8 string from a UTF-8 `String`.
///
/// This takes ownership of the `String` and does not copy.
///
......@@ -171,7 +171,7 @@ pub fn from_string(string: String) -> Wtf8Buf {
Wtf8Buf { bytes: string.into_bytes() }
}
/// Creates a WTF-8 string from an UTF-8 `&str` slice.
/// Creates a WTF-8 string from a UTF-8 `&str` slice.
///
/// This copies the content of the slice.
///
......@@ -245,7 +245,7 @@ pub fn capacity(&self) -> usize {
self.bytes.capacity()
}
/// Append an UTF-8 slice at the end of the string.
/// Append a UTF-8 slice at the end of the string.
#[inline]
pub fn push_str(&mut self, other: &str) {
self.bytes.push_all(other.as_bytes())
......@@ -527,7 +527,7 @@ pub fn as_str(&self) -> Option<&str> {
}
/// Lossily converts the string to UTF-8.
/// Returns an UTF-8 `&str` slice if the contents are well-formed in UTF-8.
/// Returns a UTF-8 `&str` slice if the contents are well-formed in UTF-8.
///
/// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”).
///
......
......@@ -4775,7 +4775,7 @@ fn parse_struct_decl_field(&mut self, allow_pub: bool) -> PResult<StructField> {
return self.parse_single_struct_field(Inherited, attrs);
}
/// Parse visibility: PUB, PRIV, or nothing
/// Parse visibility: PUB or nothing
fn parse_visibility(&mut self) -> PResult<Visibility> {
if try!(self.eat_keyword(keywords::Pub)) { Ok(Public) }
else { Ok(Inherited) }
......
......@@ -28,7 +28,7 @@ enum Result {
Status(String)
}
priv fn parse_data(len: usize, io: @io::Reader) -> Result {
fn parse_data(len: usize, io: @io::Reader) -> Result {
let res =
if (len > 0) {
let bytes = io.read_bytes(len as usize);
......@@ -42,7 +42,7 @@ enum Result {
return res;
}
priv fn parse_list(len: usize, io: @io::Reader) -> Result {
fn parse_list(len: usize, io: @io::Reader) -> Result {
let mut list: ~[Result] = ~[];
for _ in 0..len {
let v = match io.read_char() {
......@@ -55,11 +55,11 @@ enum Result {
return List(list);
}
priv fn chop(s: String) -> String {
fn chop(s: String) -> String {
s.slice(0, s.len() - 1).to_string()
}
priv fn parse_bulk(io: @io::Reader) -> Result {
fn parse_bulk(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(-1) => Nil,
......@@ -68,7 +68,7 @@ enum Result {
}
}
priv fn parse_multi(io: @io::Reader) -> Result {
fn parse_multi(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(-1) => Nil,
......@@ -78,14 +78,14 @@ enum Result {
}
}
priv fn parse_int(io: @io::Reader) -> Result {
fn parse_int(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(i) => Int(i)
}
}
priv fn parse_response(io: @io::Reader) -> Result {
fn parse_response(io: @io::Reader) -> Result {
match io.read_char() {
'$' => parse_bulk(io),
'*' => parse_multi(io),
......@@ -96,7 +96,7 @@ enum Result {
}
}
priv fn cmd_to_string(cmd: ~[String]) -> String {
fn cmd_to_string(cmd: ~[String]) -> String {
let mut res = "*".to_string();
res.push_str(cmd.len().to_string());
res.push_str("\r\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册