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 13 pull requests #34670

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
993f13a
update documentation of tuple/unit structs
durka Apr 28, 2016
a14df5c
fix Point destructuring example
durka Apr 28, 2016
beec630
"equal" -> "same type"
durka Apr 28, 2016
e1e4fbd
s/than/instead of/
durka Apr 28, 2016
56f24d7
add link to match section
durka Apr 28, 2016
170df14
Add/improve num const docs
ollie27 Jun 14, 2016
ad7d7ea
extend+improve HIR types documentation
Jun 28, 2016
5de684a
adressed @eddyb's comments
llogiq Jun 28, 2016
3f6c38c
propagate rustbuild's bootstrap.py '--help' flag
GlenDC Jun 29, 2016
2dcfa62
Correct MIN_EXP docs and improve EPSILON
ollie27 Jun 30, 2016
a0e01cc
Add doc examples for `io::Error::from_raw_os_error`.
frewsxcv Jul 2, 2016
bdea705
update cargo doc link
hhnr Jul 2, 2016
c6a04d9
Fix broken markdown link in README.
frewsxcv Jul 3, 2016
df93e18
Clarifies the meaning of the external mutability.
GuillaumeRochat Jul 3, 2016
5dfd79a
Fix spacing in for loop enumeration example
Jul 3, 2016
872d107
Fix a few typos in the code
sylvestre Jul 3, 2016
3fcb649
Fix a few typos in the doc
sylvestre Jul 3, 2016
5efc780
doc: fix and shorten comment
tshepang Jul 3, 2016
6a85183
Replace it's by its.
GuillaumeRochat Jul 5, 2016
6109ef5
Fix `std::path::Path::file_name()` doc
GuillaumeGomez Jul 5, 2016
159d1ab
Add a section about crate documentation.
GuillaumeRochat Jul 5, 2016
74e9629
show both forms of empty struct declaration
durka Jul 5, 2016
12ef728
Rollup merge of #33250 - durka:patch-19, r=steveklabnik
steveklabnik Jul 5, 2016
4b3b08f
Rollup merge of #34277 - ollie27:docs_num, r=steveklabnik
steveklabnik Jul 5, 2016
395c845
Rollup merge of #34521 - llogiq:doc-fixes, r=steveklabnik
steveklabnik Jul 5, 2016
03a1d61
Rollup merge of #34558 - GlenDC:master, r=alexcrichton
steveklabnik Jul 5, 2016
bf0cbd1
Rollup merge of #34612 - frewsxcv:io-error-from_raw_os_error, r=Guill…
steveklabnik Jul 5, 2016
be84791
Rollup merge of #34615 - rdotdk:master, r=Manishearth
steveklabnik Jul 5, 2016
868a2e0
Rollup merge of #34619 - frewsxcv:patch-30, r=apasel422
steveklabnik Jul 5, 2016
9566aaf
Rollup merge of #34621 - KaivoAnastetiks:fix/#33924, r=steveklabnik
steveklabnik Jul 5, 2016
ecd8b48
Rollup merge of #34625 - jaredmanning:patch-1, r=apasel422
steveklabnik Jul 5, 2016
b9b9247
Rollup merge of #34626 - sylvestre:master, r=Manishearth
steveklabnik Jul 5, 2016
ba40bb5
Rollup merge of #34636 - tshepang:shorten, r=GuillaumeGomez
steveklabnik Jul 5, 2016
6f987c9
Rollup merge of #34659 - GuillaumeGomez:path_file_name, r=steveklabnik
steveklabnik Jul 5, 2016
c0038f5
Rollup merge of #34667 - KaivoAnastetiks:fix/crate-documentation, r=M…
steveklabnik Jul 5, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ build.

[MSYS2][msys2] can be used to easily build Rust on Windows:

msys2: https://msys2.github.io/
[msys2]: https://msys2.github.io/

1. Grab the latest [MSYS2 installer][msys2] and go through the installer.

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def main():
parser.add_argument('--clean', action='store_true')
parser.add_argument('-v', '--verbose', action='store_true')

args = [a for a in sys.argv if a != '-h']
args = [a for a in sys.argv if a != '-h' and a != '--help']
args, _ = parser.parse_known_args(args)

# Configure initial bootstrap
Expand Down
4 changes: 2 additions & 2 deletions src/doc/book/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn call_with_ref<'a, F>(some_closure:F) -> i32
where F: Fn(&'a 32) -> i32 {
```

However this presents a problem with in our case. When you specify the explict
However this presents a problem with in our case. When you specify the explicit
lifetime on a function it binds that lifetime to the *entire* scope of the function
instead of just the invocation scope of our closure. This means that the borrow checker
will see a mutable reference in the same lifetime as our immutable reference and fail
Expand All @@ -354,7 +354,7 @@ fn call_with_ref<F>(some_closure:F) -> i32
```

This lets the Rust compiler find the minimum lifetime to invoke our closure and
satisfy the borrow checker's rules. Our function then compiles and excutes as we
satisfy the borrow checker's rules. Our function then compiles and executes as we
expect.

```rust
Expand Down
11 changes: 11 additions & 0 deletions src/doc/book/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,17 @@ you have a module in `foo.rs`, you'll often open its code and see this:
//! The `foo` module contains a lot of useful functionality blah blah blah
```

### Crate documentation

Crates can be documented by placing an inner doc comment (`//!`) at the
beginning of the crate root, aka `lib.rs`:

```rust
//! This is documentation for the `foo` crate.
//!
//! The foo crate is meant to be used for bar.
```

### Documentation comment style

Check out [RFC 505][rfc505] for full conventions around the style and format of
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ We could also use a range of versions.
[Cargo’s documentation][cargodoc] contains more details.

[semver]: http://semver.org
[cargodoc]: http://doc.crates.io/crates-io.html
[cargodoc]: http://doc.crates.io/specifying-dependencies.html

Now, without changing any of our code, let’s build our project:

Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ When you need to keep track of how many times you already looped, you can use th
#### On ranges:

```rust
for (i,j) in (5..10).enumerate() {
for (i, j) in (5..10).enumerate() {
println!("i = {} and j = {}", i, j);
}
```
Expand Down
4 changes: 2 additions & 2 deletions src/doc/book/mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Note that here, the `x` is mutable, but not the `y`.
# Interior vs. Exterior Mutability

However, when we say something is ‘immutable’ in Rust, that doesn’t mean that
it’s not able to be changed: we mean something has ‘exterior mutability’. Consider,
for example, [`Arc<T>`][arc]:
it’s not able to be changed: we are referring to its ‘exterior mutability’ that
in this case is immutable. Consider, for example, [`Arc<T>`][arc]:

```rust
use std::sync::Arc;
Expand Down
73 changes: 50 additions & 23 deletions src/doc/book/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,51 @@ struct Point(i32, i32, i32);
let black = Color(0, 0, 0);
let origin = Point(0, 0, 0);
```
Here, `black` and `origin` are not equal, even though they contain the same
values.

It is almost always better to use a `struct` than a tuple struct. We
would write `Color` and `Point` like this instead:
Here, `black` and `origin` are not the same type, even though they contain the
same values.

The members of a tuple struct may be accessed by dot notation or destructuring
`let`, just like regular tuples:

```rust
# struct Color(i32, i32, i32);
# struct Point(i32, i32, i32);
# let black = Color(0, 0, 0);
# let origin = Point(0, 0, 0);
let black_r = black.0;
let Point(_, origin_y, origin_z) = origin;
```

Patterns like `Point(_, origin_y, origin_z)` are also used in
[match expressions][match].

One case when a tuple struct is very useful is when it has only one element.
We call this the ‘newtype’ pattern, because it allows you to create a new type
that is distinct from its contained value and also expresses its own semantic
meaning:

```rust
struct Inches(i32);

let length = Inches(10);

let Inches(integer_length) = length;
println!("length is {} inches", integer_length);
```

As above, you can extract the inner integer type through a destructuring `let`.
In this case, the `let Inches(integer_length)` assigns `10` to `integer_length`.
We could have used dot notation to do the same thing:

```rust
# struct Inches(i32);
# let length = Inches(10);
let integer_length = length.0;
```

It's always possible to use a `struct` instead of a tuple struct, and can be
clearer. We could write `Color` and `Point` like this instead:

```rust
struct Color {
Expand All @@ -187,32 +227,19 @@ Good names are important, and while values in a tuple struct can be
referenced with dot notation as well, a `struct` gives us actual names,
rather than positions.

There _is_ one case when a tuple struct is very useful, though, and that is when
it has only one element. We call this the ‘newtype’ pattern, because
it allows you to create a new type that is distinct from its contained value
and also expresses its own semantic meaning:

```rust
struct Inches(i32);

let length = Inches(10);

let Inches(integer_length) = length;
println!("length is {} inches", integer_length);
```

As you can see here, you can extract the inner integer type through a
destructuring `let`, as with regular tuples. In this case, the
`let Inches(integer_length)` assigns `10` to `integer_length`.
[match]: match.html

# Unit-like structs

You can define a `struct` with no members at all:

```rust
struct Electron;
struct Electron {} // use empty braces...
struct Proton; // ...or just a semicolon

let x = Electron;
// whether you declared the struct with braces or not, do the same when creating one
let x = Electron {};
let y = Proton;
```

Such a `struct` is called ‘unit-like’ because it resembles the empty
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ one.

Cargo will ignore files in subdirectories of the `tests/` directory.
Therefore shared modules in integrations tests are possible.
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
For example `tests/common/mod.rs` is not separately compiled by cargo but can
be imported in every test with `mod common;`

That's all there is to the `tests` directory. The `tests` module isn't needed
Expand Down
60 changes: 30 additions & 30 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,121 +20,121 @@ use mem;
use num::Float;
use num::FpCategory as Fp;

/// The radix or base of the internal representation of `f32`.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const RADIX: u32 = 2;

/// Number of significant digits in base 2.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const MANTISSA_DIGITS: u32 = 24;
/// Approximate number of significant digits in base 10.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const DIGITS: u32 = 6;

/// Difference between `1.0` and the next largest representable number.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const EPSILON: f32 = 1.19209290e-07_f32;

/// Smallest finite f32 value
/// Smallest finite `f32` value.
#[stable(feature = "rust1", since = "1.0.0")]
pub const MIN: f32 = -3.40282347e+38_f32;
/// Smallest positive, normalized f32 value
/// Smallest positive normal `f32` value.
#[stable(feature = "rust1", since = "1.0.0")]
pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
/// Largest finite f32 value
/// Largest finite `f32` value.
#[stable(feature = "rust1", since = "1.0.0")]
pub const MAX: f32 = 3.40282347e+38_f32;

/// One greater than the minimum possible normal power of 2 exponent.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const MIN_EXP: i32 = -125;
/// Maximum possible power of 2 exponent.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const MAX_EXP: i32 = 128;

/// Minimum possible normal power of 10 exponent.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const MIN_10_EXP: i32 = -37;
/// Maximum possible power of 10 exponent.
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const MAX_10_EXP: i32 = 38;

/// Not a Number (NaN).
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const NAN: f32 = 0.0_f32/0.0_f32;
/// Infinity (∞).
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const INFINITY: f32 = 1.0_f32/0.0_f32;
/// Negative infinity (-∞).
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32;

/// Basic mathematical constants.
#[stable(feature = "rust1", since = "1.0.0")]
pub mod consts {
// FIXME: replace with mathematical constants from cmath.

/// Archimedes' constant
/// Archimedes' constant (π)
#[stable(feature = "rust1", since = "1.0.0")]
pub const PI: f32 = 3.14159265358979323846264338327950288_f32;

/// pi/2.0
/// π/2
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_PI_2: f32 = 1.57079632679489661923132169163975144_f32;

/// pi/3.0
/// π/3
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_PI_3: f32 = 1.04719755119659774615421446109316763_f32;

/// pi/4.0
/// π/4
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_PI_4: f32 = 0.785398163397448309615660845819875721_f32;

/// pi/6.0
/// π/6
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_PI_6: f32 = 0.52359877559829887307710723054658381_f32;

/// pi/8.0
/// π/8
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_PI_8: f32 = 0.39269908169872415480783042290993786_f32;

/// 1.0/pi
/// 1
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32;

/// 2.0/pi
/// 2
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_2_PI: f32 = 0.636619772367581343075535053490057448_f32;

/// 2.0/sqrt(pi)
/// 2/sqrt(π)
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_2_SQRT_PI: f32 = 1.12837916709551257389615890312154517_f32;

/// sqrt(2.0)
/// sqrt(2)
#[stable(feature = "rust1", since = "1.0.0")]
pub const SQRT_2: f32 = 1.41421356237309504880168872420969808_f32;

/// 1.0/sqrt(2.0)
/// 1/sqrt(2)
#[stable(feature = "rust1", since = "1.0.0")]
pub const FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039_f32;

/// Euler's number
/// Euler's number (e)
#[stable(feature = "rust1", since = "1.0.0")]
pub const E: f32 = 2.71828182845904523536028747135266250_f32;

/// log2(e)
/// log<sub>2</sub>(e)
#[stable(feature = "rust1", since = "1.0.0")]
pub const LOG2_E: f32 = 1.44269504088896340735992468100189214_f32;

/// log10(e)
/// log<sub>10</sub>(e)
#[stable(feature = "rust1", since = "1.0.0")]
pub const LOG10_E: f32 = 0.434294481903251827651128918916605082_f32;

/// ln(2.0)
/// ln(2)
#[stable(feature = "rust1", since = "1.0.0")]
pub const LN_2: f32 = 0.693147180559945309417232121458176568_f32;

/// ln(10.0)
/// ln(10)
#[stable(feature = "rust1", since = "1.0.0")]
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
}
Expand Down
Loading