Auto merge of #25735 - oli-obk:rollup, r=steveklabnik
- Successful merges: #25681, #25687, #25695, #25697, #25702, #25703, #25709, #25710, #25714, #25715, #25716, #25722 - Failed merges:
This commit is contained in:
commit
a33b808ac0
8
configure
vendored
8
configure
vendored
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
msg() {
|
||||
echo "configure: $1"
|
||||
echo "configure: $*"
|
||||
}
|
||||
|
||||
step_msg() {
|
||||
@ -33,8 +33,8 @@ need_ok() {
|
||||
|
||||
need_cmd() {
|
||||
if command -v $1 >/dev/null 2>&1
|
||||
then msg "found program $1"
|
||||
else err "need program $1"
|
||||
then msg "found program '$1'"
|
||||
else err "program '$1' is missing, please install it"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -986,7 +986,7 @@ then
|
||||
| cut -d ' ' -f 2)
|
||||
|
||||
case $CFG_CLANG_VERSION in
|
||||
(3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
|
||||
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7*)
|
||||
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
|
||||
if [ -z "$CC" ]
|
||||
then
|
||||
|
@ -2003,6 +2003,10 @@ arbitrarily complex configurations through nesting.
|
||||
|
||||
The following configurations must be defined by the implementation:
|
||||
|
||||
* `debug_assertions`. Enabled by default when compiling without optimizations.
|
||||
This can be used to enable extra debugging code in development but not in
|
||||
production. For example, it controls the behavior of the standard library's
|
||||
`debug_assert!` macro.
|
||||
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
|
||||
`"mips"`, `"powerpc"`, `"arm"`, or `"aarch64"`.
|
||||
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
|
||||
|
@ -2,26 +2,28 @@
|
||||
|
||||
For our second project, let’s look at a classic concurrency problem. It’s
|
||||
called ‘the dining philosophers’. It was originally conceived by Dijkstra in
|
||||
1965, but we’ll use the version from [this paper][paper] by Tony Hoare in 1985.
|
||||
1965, but we’ll use a lightly adapted version from [this paper][paper] by Tony
|
||||
Hoare in 1985.
|
||||
|
||||
[paper]: http://www.usingcsp.com/cspbook.pdf
|
||||
|
||||
> In ancient times, a wealthy philanthropist endowed a College to accommodate
|
||||
> five eminent philosophers. Each philosopher had a room in which she could
|
||||
> engage in her professional activity of thinking; there was also a common
|
||||
> five eminent philosophers. Each philosopher had a room in which they could
|
||||
> engage in their professional activity of thinking; there was also a common
|
||||
> dining room, furnished with a circular table, surrounded by five chairs, each
|
||||
> labelled by the name of the philosopher who was to sit in it. They sat
|
||||
> anticlockwise around the table. To the left of each philosopher there was
|
||||
> laid a golden fork, and in the centre stood a large bowl of spaghetti, which
|
||||
> was constantly replenished. A philosopher was expected to spend most of her
|
||||
> time thinking; but when she felt hungry, she went to the dining room, sat down
|
||||
> in her own chair, picked up her own fork on her left, and plunged it into the
|
||||
> spaghetti. But such is the tangled nature of spaghetti that a second fork is
|
||||
> required to carry it to the mouth. The philosopher therefore had also to pick
|
||||
> up the fork on her right. When she was finished she would put down both her
|
||||
> forks, get up from her chair, and continue thinking. Of course, a fork can be
|
||||
> used by only one philosopher at a time. If the other philosopher wants it, she
|
||||
> just has to wait until the fork is available again.
|
||||
> was constantly replenished. A philosopher was expected to spend most of
|
||||
> their time thinking; but when they felt hungry, they went to the dining
|
||||
> room, sat down in their own chair, picked up their own fork on their left,
|
||||
> and plunged it into the spaghetti. But such is the tangled nature of
|
||||
> spaghetti that a second fork is required to carry it to the mouth. The
|
||||
> philosopher therefore had also to pick up the fork on their right. When
|
||||
> they were finished they would put down both their forks, get up from their
|
||||
> chair, and continue thinking. Of course, a fork can be used by only one
|
||||
> philosopher at a time. If the other philosopher wants it, they just have
|
||||
> to wait until the fork is available again.
|
||||
|
||||
This classic problem shows off a few different elements of concurrency. The
|
||||
reason is that it's actually slightly tricky to implement: a simple
|
||||
@ -60,10 +62,10 @@ impl Philosopher {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let p1 = Philosopher::new("Baruch Spinoza");
|
||||
let p1 = Philosopher::new("Judith Butler");
|
||||
let p2 = Philosopher::new("Gilles Deleuze");
|
||||
let p3 = Philosopher::new("Karl Marx");
|
||||
let p4 = Philosopher::new("Friedrich Nietzsche");
|
||||
let p4 = Philosopher::new("Emma Goldman");
|
||||
let p5 = Philosopher::new("Michel Foucault");
|
||||
}
|
||||
```
|
||||
@ -159,10 +161,10 @@ look at `main()` again:
|
||||
# }
|
||||
#
|
||||
fn main() {
|
||||
let p1 = Philosopher::new("Baruch Spinoza");
|
||||
let p1 = Philosopher::new("Judith Butler");
|
||||
let p2 = Philosopher::new("Gilles Deleuze");
|
||||
let p3 = Philosopher::new("Karl Marx");
|
||||
let p4 = Philosopher::new("Friedrich Nietzsche");
|
||||
let p4 = Philosopher::new("Emma Goldman");
|
||||
let p5 = Philosopher::new("Michel Foucault");
|
||||
}
|
||||
```
|
||||
@ -176,10 +178,10 @@ that `new()` function, it would look like this:
|
||||
# name: String,
|
||||
# }
|
||||
fn main() {
|
||||
let p1 = Philosopher { name: "Baruch Spinoza".to_string() };
|
||||
let p1 = Philosopher { name: "Judith Butler".to_string() };
|
||||
let p2 = Philosopher { name: "Gilles Deleuze".to_string() };
|
||||
let p3 = Philosopher { name: "Karl Marx".to_string() };
|
||||
let p4 = Philosopher { name: "Friedrich Nietzche".to_string() };
|
||||
let p4 = Philosopher { name: "Emma Goldman".to_string() };
|
||||
let p5 = Philosopher { name: "Michel Foucault".to_string() };
|
||||
}
|
||||
```
|
||||
@ -211,10 +213,10 @@ impl Philosopher {
|
||||
|
||||
fn main() {
|
||||
let philosophers = vec![
|
||||
Philosopher::new("Baruch Spinoza"),
|
||||
Philosopher::new("Judith Butler"),
|
||||
Philosopher::new("Gilles Deleuze"),
|
||||
Philosopher::new("Karl Marx"),
|
||||
Philosopher::new("Friedrich Nietzsche"),
|
||||
Philosopher::new("Emma Goldman"),
|
||||
Philosopher::new("Michel Foucault"),
|
||||
];
|
||||
|
||||
@ -247,10 +249,10 @@ mention they’re done eating. Running this program should give you the followin
|
||||
output:
|
||||
|
||||
```text
|
||||
Baruch Spinoza is done eating.
|
||||
Judith Butler is done eating.
|
||||
Gilles Deleuze is done eating.
|
||||
Karl Marx is done eating.
|
||||
Friedrich Nietzsche is done eating.
|
||||
Emma Goldman is done eating.
|
||||
Michel Foucault is done eating.
|
||||
```
|
||||
|
||||
@ -285,10 +287,10 @@ impl Philosopher {
|
||||
|
||||
fn main() {
|
||||
let philosophers = vec![
|
||||
Philosopher::new("Baruch Spinoza"),
|
||||
Philosopher::new("Judith Butler"),
|
||||
Philosopher::new("Gilles Deleuze"),
|
||||
Philosopher::new("Karl Marx"),
|
||||
Philosopher::new("Friedrich Nietzsche"),
|
||||
Philosopher::new("Emma Goldman"),
|
||||
Philosopher::new("Michel Foucault"),
|
||||
];
|
||||
|
||||
@ -323,14 +325,14 @@ simulate the time it takes a philosopher to eat.
|
||||
If you run this program, you should see each philosopher eat in turn:
|
||||
|
||||
```text
|
||||
Baruch Spinoza is eating.
|
||||
Baruch Spinoza is done eating.
|
||||
Judith Butler is eating.
|
||||
Judith Butler is done eating.
|
||||
Gilles Deleuze is eating.
|
||||
Gilles Deleuze is done eating.
|
||||
Karl Marx is eating.
|
||||
Karl Marx is done eating.
|
||||
Friedrich Nietzsche is eating.
|
||||
Friedrich Nietzsche is done eating.
|
||||
Emma Goldman is eating.
|
||||
Emma Goldman is done eating.
|
||||
Michel Foucault is eating.
|
||||
Michel Foucault is done eating.
|
||||
```
|
||||
@ -366,10 +368,10 @@ impl Philosopher {
|
||||
|
||||
fn main() {
|
||||
let philosophers = vec![
|
||||
Philosopher::new("Baruch Spinoza"),
|
||||
Philosopher::new("Judith Butler"),
|
||||
Philosopher::new("Gilles Deleuze"),
|
||||
Philosopher::new("Karl Marx"),
|
||||
Philosopher::new("Friedrich Nietzsche"),
|
||||
Philosopher::new("Emma Goldman"),
|
||||
Philosopher::new("Michel Foucault"),
|
||||
];
|
||||
|
||||
@ -458,11 +460,11 @@ We have multi-threading!
|
||||
```text
|
||||
Gilles Deleuze is eating.
|
||||
Gilles Deleuze is done eating.
|
||||
Friedrich Nietzsche is eating.
|
||||
Friedrich Nietzsche is done eating.
|
||||
Emma Goldman is eating.
|
||||
Emma Goldman is done eating.
|
||||
Michel Foucault is eating.
|
||||
Baruch Spinoza is eating.
|
||||
Baruch Spinoza is done eating.
|
||||
Judith Butler is eating.
|
||||
Judith Butler is done eating.
|
||||
Karl Marx is eating.
|
||||
Karl Marx is done eating.
|
||||
Michel Foucault is done eating.
|
||||
@ -532,10 +534,10 @@ fn main() {
|
||||
]});
|
||||
|
||||
let philosophers = vec![
|
||||
Philosopher::new("Baruch Spinoza", 0, 1),
|
||||
Philosopher::new("Judith Butler", 0, 1),
|
||||
Philosopher::new("Gilles Deleuze", 1, 2),
|
||||
Philosopher::new("Karl Marx", 2, 3),
|
||||
Philosopher::new("Friedrich Nietzsche", 3, 4),
|
||||
Philosopher::new("Emma Goldman", 3, 4),
|
||||
Philosopher::new("Michel Foucault", 0, 4),
|
||||
];
|
||||
|
||||
@ -643,10 +645,10 @@ count will go up, and when each thread ends, it will go back down.
|
||||
|
||||
```rust,ignore
|
||||
let philosophers = vec![
|
||||
Philosopher::new("Baruch Spinoza", 0, 1),
|
||||
Philosopher::new("Judith Butler", 0, 1),
|
||||
Philosopher::new("Gilles Deleuze", 1, 2),
|
||||
Philosopher::new("Karl Marx", 2, 3),
|
||||
Philosopher::new("Friedrich Nietzsche", 3, 4),
|
||||
Philosopher::new("Emma Goldman", 3, 4),
|
||||
Philosopher::new("Michel Foucault", 0, 4),
|
||||
];
|
||||
```
|
||||
@ -679,12 +681,12 @@ and so you’ll get some output like this:
|
||||
|
||||
```text
|
||||
Gilles Deleuze is eating.
|
||||
Friedrich Nietzsche is eating.
|
||||
Friedrich Nietzsche is done eating.
|
||||
Emma Goldman is eating.
|
||||
Emma Goldman is done eating.
|
||||
Gilles Deleuze is done eating.
|
||||
Baruch Spinoza is eating.
|
||||
Judith Butler is eating.
|
||||
Karl Marx is eating.
|
||||
Baruch Spinoza is done eating.
|
||||
Judith Butler is done eating.
|
||||
Michel Foucault is eating.
|
||||
Karl Marx is done eating.
|
||||
Michel Foucault is done eating.
|
||||
|
@ -637,7 +637,7 @@ When we wrote `let guess = String::new()`, Rust was able to infer that `guess`
|
||||
should be a `String`, and so it doesn’t make us write out the type. And with
|
||||
our `secret_number`, there are a number of types which can have a value
|
||||
between one and a hundred: `i32`, a thirty-two-bit number, or `u32`, an
|
||||
unsigned thirty-two-bit number, or `i64`, a sixty-four-bit number. Or others.
|
||||
unsigned thirty-two-bit number, or `i64`, a sixty-four-bit number or others.
|
||||
So far, that hasn’t mattered, and so Rust defaults to an `i32`. However, here,
|
||||
Rust doesn’t know how to compare the `guess` and the `secret_number`. They
|
||||
need to be the same type. Ultimately, we want to convert the `String` we
|
||||
|
@ -144,7 +144,7 @@
|
||||
//! // At the end of the method, gadget_owner, gadget1 and gadget2 get
|
||||
//! // destroyed. There are now no strong (`Rc<T>`) references to the gadgets.
|
||||
//! // Once they get destroyed, the Gadgets get destroyed. This zeroes the
|
||||
//! // reference count on Gadget Man, so he gets destroyed as well.
|
||||
//! // reference count on Gadget Man, they get destroyed as well.
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
|
@ -1110,9 +1110,8 @@ impl str {
|
||||
/// such as leaving a combining character as the first code point of the
|
||||
/// string.
|
||||
///
|
||||
/// Due to the design of UTF-8, this operation is `O(end)`. See `slice`,
|
||||
/// `slice_to` and `slice_from` for `O(1)` variants that use byte indices
|
||||
/// rather than code point indices.
|
||||
/// Due to the design of UTF-8, this operation is `O(end)`. Use slicing
|
||||
/// syntax if you want to use byte indices rather than codepoint indices.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
|
@ -11,7 +11,8 @@
|
||||
//! A growable list type with heap-allocated contents, written `Vec<T>` but
|
||||
//! pronounced 'vector.'
|
||||
//!
|
||||
//! Vectors have `O(1)` indexing, push (to the end) and pop (from the end).
|
||||
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
|
||||
//! `O(1)` pop (from the end).
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
|
@ -73,11 +73,11 @@ macro_rules! zero_one_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Zero for $t {
|
||||
#[inline]
|
||||
fn zero() -> $t { 0 }
|
||||
fn zero() -> Self { 0 }
|
||||
}
|
||||
impl One for $t {
|
||||
#[inline]
|
||||
fn one() -> $t { 1 }
|
||||
fn one() -> Self { 1 }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
@ -87,20 +87,20 @@ macro_rules! zero_one_impl_float {
|
||||
($($t:ty)*) => ($(
|
||||
impl Zero for $t {
|
||||
#[inline]
|
||||
fn zero() -> $t { 0.0 }
|
||||
fn zero() -> Self { 0.0 }
|
||||
}
|
||||
impl One for $t {
|
||||
#[inline]
|
||||
fn one() -> $t { 1.0 }
|
||||
fn one() -> Self { 1.0 }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
zero_one_impl_float! { f32 f64 }
|
||||
|
||||
macro_rules! checked_op {
|
||||
($T:ty, $U:ty, $op:path, $x:expr, $y:expr) => {{
|
||||
($U:ty, $op:path, $x:expr, $y:expr) => {{
|
||||
let (result, overflowed) = unsafe { $op($x as $U, $y as $U) };
|
||||
if overflowed { None } else { Some(result as $T) }
|
||||
if overflowed { None } else { Some(result as Self) }
|
||||
}}
|
||||
}
|
||||
|
||||
@ -110,22 +110,22 @@ unsafe fn bswap8(x: u8) -> u8 { x }
|
||||
|
||||
// `Int` + `SignedInt` implemented for signed integers
|
||||
macro_rules! int_impl {
|
||||
($T:ident = $ActualT:ty, $UnsignedT:ty, $BITS:expr,
|
||||
($ActualT:ty, $UnsignedT:ty, $BITS:expr,
|
||||
$add_with_overflow:path,
|
||||
$sub_with_overflow:path,
|
||||
$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)
|
||||
pub fn min_value() -> Self {
|
||||
(-1 as Self) << ($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
|
||||
pub fn max_value() -> Self {
|
||||
let min = Self::min_value(); !min
|
||||
}
|
||||
|
||||
/// Converts a string slice in a given base to an integer.
|
||||
@ -139,7 +139,7 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow(deprecated)]
|
||||
pub fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseIntError> {
|
||||
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError> {
|
||||
from_str_radix(src, radix)
|
||||
}
|
||||
|
||||
@ -216,8 +216,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn rotate_left(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_left(n) as $T
|
||||
pub fn rotate_left(self, n: u32) -> Self {
|
||||
(self as $UnsignedT).rotate_left(n) as Self
|
||||
}
|
||||
|
||||
/// Shifts the bits to the right by a specified amount, `n`,
|
||||
@ -234,8 +234,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn rotate_right(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_right(n) as $T
|
||||
pub fn rotate_right(self, n: u32) -> Self {
|
||||
(self as $UnsignedT).rotate_right(n) as Self
|
||||
}
|
||||
|
||||
/// Reverses the byte order of the integer.
|
||||
@ -250,8 +250,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn swap_bytes(self) -> $T {
|
||||
(self as $UnsignedT).swap_bytes() as $T
|
||||
pub fn swap_bytes(self) -> Self {
|
||||
(self as $UnsignedT).swap_bytes() as Self
|
||||
}
|
||||
|
||||
/// Converts an integer from big endian to the target's endianness.
|
||||
@ -272,7 +272,7 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn from_be(x: $T) -> $T {
|
||||
pub fn from_be(x: Self) -> Self {
|
||||
if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn from_le(x: $T) -> $T {
|
||||
pub fn from_le(x: Self) -> Self {
|
||||
if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_be(self) -> $T { // or not to be?
|
||||
pub fn to_be(self) -> Self { // or not to be?
|
||||
if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_le(self) -> $T {
|
||||
pub fn to_le(self) -> Self {
|
||||
if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -353,8 +353,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_add(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $add_with_overflow, self, other)
|
||||
pub fn checked_add(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $add_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer subtraction. Computes `self - other`, returning
|
||||
@ -368,8 +368,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_sub(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $sub_with_overflow, self, other)
|
||||
pub fn checked_sub(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $sub_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer multiplication. Computes `self * other`, returning
|
||||
@ -383,8 +383,8 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_mul(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $mul_with_overflow, self, other)
|
||||
pub fn checked_mul(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $mul_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer division. Computes `self / other`, returning `None`
|
||||
@ -399,10 +399,10 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_div(self, v: $T) -> Option<$T> {
|
||||
pub fn checked_div(self, v: Self) -> Option<Self> {
|
||||
match v {
|
||||
0 => None,
|
||||
-1 if self == <$T>::min_value()
|
||||
-1 if self == Self::min_value()
|
||||
=> None,
|
||||
v => Some(self / v),
|
||||
}
|
||||
@ -412,11 +412,11 @@ macro_rules! int_impl {
|
||||
/// the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_add(self, other: $T) -> $T {
|
||||
pub fn saturating_add(self, other: Self) -> Self {
|
||||
match self.checked_add(other) {
|
||||
Some(x) => x,
|
||||
None if other >= <$T as Zero>::zero() => <$T>::max_value(),
|
||||
None => <$T>::min_value(),
|
||||
None if other >= Self::zero() => Self::max_value(),
|
||||
None => Self::min_value(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,11 +424,11 @@ macro_rules! int_impl {
|
||||
/// at the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_sub(self, other: $T) -> $T {
|
||||
pub fn saturating_sub(self, other: Self) -> Self {
|
||||
match self.checked_sub(other) {
|
||||
Some(x) => x,
|
||||
None if other >= <$T as Zero>::zero() => <$T>::min_value(),
|
||||
None => <$T>::max_value(),
|
||||
None if other >= Self::zero() => Self::min_value(),
|
||||
None => Self::max_value(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ macro_rules! int_impl {
|
||||
/// wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_add(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_add(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_add(self, rhs)
|
||||
}
|
||||
@ -446,7 +446,7 @@ macro_rules! int_impl {
|
||||
/// wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_sub(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_sub(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_sub(self, rhs)
|
||||
}
|
||||
@ -456,7 +456,7 @@ macro_rules! int_impl {
|
||||
/// other`, wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_mul(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_mul(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_mul(self, rhs)
|
||||
}
|
||||
@ -473,7 +473,7 @@ macro_rules! int_impl {
|
||||
/// itself..
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_div(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_div(self, rhs: Self) -> Self {
|
||||
self.overflowing_div(rhs).0
|
||||
}
|
||||
|
||||
@ -486,7 +486,7 @@ macro_rules! int_impl {
|
||||
/// minimal value). In such a case, this function returns `0`.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_rem(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_rem(self, rhs: Self) -> Self {
|
||||
self.overflowing_rem(rhs).0
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ macro_rules! int_impl {
|
||||
/// a case, this function returns `MIN` itself.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_neg(self) -> $T {
|
||||
pub fn wrapping_neg(self) -> Self {
|
||||
self.overflowing_neg().0
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ macro_rules! int_impl {
|
||||
/// would cause the shift to exceed the bitwidth of the type.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_shl(self, rhs: u32) -> $T {
|
||||
pub fn wrapping_shl(self, rhs: u32) -> Self {
|
||||
self.overflowing_shl(rhs).0
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ macro_rules! int_impl {
|
||||
/// would cause the shift to exceed the bitwidth of the type.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_shr(self, rhs: u32) -> $T {
|
||||
pub fn wrapping_shr(self, rhs: u32) -> Self {
|
||||
self.overflowing_shr(rhs).0
|
||||
}
|
||||
|
||||
@ -533,9 +533,9 @@ macro_rules! int_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn pow(self, mut exp: u32) -> $T {
|
||||
pub fn pow(self, mut exp: u32) -> Self {
|
||||
let mut base = self;
|
||||
let mut acc = <$T as One>::one();
|
||||
let mut acc = Self::one();
|
||||
|
||||
let mut prev_base = self;
|
||||
let mut base_oflo = false;
|
||||
@ -569,7 +569,7 @@ macro_rules! int_impl {
|
||||
/// optimized code will return `i32::min_value()` without a panic.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn abs(self) -> $T {
|
||||
pub fn abs(self) -> Self {
|
||||
if self.is_negative() {
|
||||
// Note that the #[inline] above means that the overflow
|
||||
// semantics of this negation depend on the crate we're being
|
||||
@ -587,7 +587,7 @@ macro_rules! int_impl {
|
||||
/// - `-1` if the number is negative
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn signum(self) -> $T {
|
||||
pub fn signum(self) -> Self {
|
||||
match self {
|
||||
n if n > 0 => 1,
|
||||
0 => 0,
|
||||
@ -611,7 +611,7 @@ macro_rules! int_impl {
|
||||
|
||||
#[lang = "i8"]
|
||||
impl i8 {
|
||||
int_impl! { i8 = i8, u8, 8,
|
||||
int_impl! { i8, u8, 8,
|
||||
intrinsics::i8_add_with_overflow,
|
||||
intrinsics::i8_sub_with_overflow,
|
||||
intrinsics::i8_mul_with_overflow }
|
||||
@ -619,7 +619,7 @@ impl i8 {
|
||||
|
||||
#[lang = "i16"]
|
||||
impl i16 {
|
||||
int_impl! { i16 = i16, u16, 16,
|
||||
int_impl! { i16, u16, 16,
|
||||
intrinsics::i16_add_with_overflow,
|
||||
intrinsics::i16_sub_with_overflow,
|
||||
intrinsics::i16_mul_with_overflow }
|
||||
@ -627,7 +627,7 @@ impl i16 {
|
||||
|
||||
#[lang = "i32"]
|
||||
impl i32 {
|
||||
int_impl! { i32 = i32, u32, 32,
|
||||
int_impl! { i32, u32, 32,
|
||||
intrinsics::i32_add_with_overflow,
|
||||
intrinsics::i32_sub_with_overflow,
|
||||
intrinsics::i32_mul_with_overflow }
|
||||
@ -635,7 +635,7 @@ impl i32 {
|
||||
|
||||
#[lang = "i64"]
|
||||
impl i64 {
|
||||
int_impl! { i64 = i64, u64, 64,
|
||||
int_impl! { i64, u64, 64,
|
||||
intrinsics::i64_add_with_overflow,
|
||||
intrinsics::i64_sub_with_overflow,
|
||||
intrinsics::i64_mul_with_overflow }
|
||||
@ -644,7 +644,7 @@ impl i64 {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
int_impl! { isize = i32, u32, 32,
|
||||
int_impl! { i32, u32, 32,
|
||||
intrinsics::i32_add_with_overflow,
|
||||
intrinsics::i32_sub_with_overflow,
|
||||
intrinsics::i32_mul_with_overflow }
|
||||
@ -653,7 +653,7 @@ impl isize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
int_impl! { isize = i64, u64, 64,
|
||||
int_impl! { i64, u64, 64,
|
||||
intrinsics::i64_add_with_overflow,
|
||||
intrinsics::i64_sub_with_overflow,
|
||||
intrinsics::i64_mul_with_overflow }
|
||||
@ -661,7 +661,7 @@ impl isize {
|
||||
|
||||
// `Int` + `UnsignedInt` implemented for signed integers
|
||||
macro_rules! uint_impl {
|
||||
($T:ty = $ActualT:ty, $BITS:expr,
|
||||
($ActualT:ty, $BITS:expr,
|
||||
$ctpop:path,
|
||||
$ctlz:path,
|
||||
$cttz:path,
|
||||
@ -671,11 +671,11 @@ macro_rules! uint_impl {
|
||||
$mul_with_overflow:path) => {
|
||||
/// Returns the smallest value that can be represented by this integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn min_value() -> $T { 0 }
|
||||
pub fn min_value() -> Self { 0 }
|
||||
|
||||
/// Returns the largest value that can be represented by this integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn max_value() -> $T { !0 }
|
||||
pub fn max_value() -> Self { !0 }
|
||||
|
||||
/// Converts a string slice in a given base to an integer.
|
||||
///
|
||||
@ -692,7 +692,7 @@ macro_rules! uint_impl {
|
||||
/// Otherwise, `Ok(n)` where `n` is the integer represented by `src`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow(deprecated)]
|
||||
pub fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseIntError> {
|
||||
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError> {
|
||||
from_str_radix(src, radix)
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn rotate_left(self, n: u32) -> $T {
|
||||
pub fn rotate_left(self, n: u32) -> Self {
|
||||
// Protect against undefined behaviour for over-long bit shifts
|
||||
let n = n % $BITS;
|
||||
(self << n) | (self >> (($BITS - n) % $BITS))
|
||||
@ -804,7 +804,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn rotate_right(self, n: u32) -> $T {
|
||||
pub fn rotate_right(self, n: u32) -> Self {
|
||||
// Protect against undefined behaviour for over-long bit shifts
|
||||
let n = n % $BITS;
|
||||
(self >> n) | (self << (($BITS - n) % $BITS))
|
||||
@ -822,8 +822,8 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn swap_bytes(self) -> $T {
|
||||
unsafe { $bswap(self as $ActualT) as $T }
|
||||
pub fn swap_bytes(self) -> Self {
|
||||
unsafe { $bswap(self as $ActualT) as Self }
|
||||
}
|
||||
|
||||
/// Converts an integer from big endian to the target's endianness.
|
||||
@ -844,7 +844,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn from_be(x: $T) -> $T {
|
||||
pub fn from_be(x: Self) -> Self {
|
||||
if cfg!(target_endian = "big") { x } else { x.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -866,7 +866,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn from_le(x: $T) -> $T {
|
||||
pub fn from_le(x: Self) -> Self {
|
||||
if cfg!(target_endian = "little") { x } else { x.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_be(self) -> $T { // or not to be?
|
||||
pub fn to_be(self) -> Self { // or not to be?
|
||||
if cfg!(target_endian = "big") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -910,7 +910,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn to_le(self) -> $T {
|
||||
pub fn to_le(self) -> Self {
|
||||
if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
@ -925,8 +925,8 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_add(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $add_with_overflow, self, other)
|
||||
pub fn checked_add(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $add_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer subtraction. Computes `self - other`, returning
|
||||
@ -940,8 +940,8 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_sub(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $sub_with_overflow, self, other)
|
||||
pub fn checked_sub(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $sub_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer multiplication. Computes `self * other`, returning
|
||||
@ -955,8 +955,8 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_mul(self, other: $T) -> Option<$T> {
|
||||
checked_op!($T, $ActualT, $mul_with_overflow, self, other)
|
||||
pub fn checked_mul(self, other: Self) -> Option<Self> {
|
||||
checked_op!($ActualT, $mul_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer division. Computes `self / other`, returning `None`
|
||||
@ -971,7 +971,7 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn checked_div(self, v: $T) -> Option<$T> {
|
||||
pub fn checked_div(self, v: Self) -> Option<Self> {
|
||||
match v {
|
||||
0 => None,
|
||||
v => Some(self / v),
|
||||
@ -982,11 +982,11 @@ macro_rules! uint_impl {
|
||||
/// the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_add(self, other: $T) -> $T {
|
||||
pub fn saturating_add(self, other: Self) -> Self {
|
||||
match self.checked_add(other) {
|
||||
Some(x) => x,
|
||||
None if other >= <$T as Zero>::zero() => <$T>::max_value(),
|
||||
None => <$T>::min_value(),
|
||||
None if other >= Self::zero() => Self::max_value(),
|
||||
None => Self::min_value(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -994,11 +994,11 @@ macro_rules! uint_impl {
|
||||
/// at the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_sub(self, other: $T) -> $T {
|
||||
pub fn saturating_sub(self, other: Self) -> Self {
|
||||
match self.checked_sub(other) {
|
||||
Some(x) => x,
|
||||
None if other >= <$T as Zero>::zero() => <$T>::min_value(),
|
||||
None => <$T>::max_value(),
|
||||
None if other >= Self::zero() => Self::min_value(),
|
||||
None => Self::max_value(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1006,7 +1006,7 @@ macro_rules! uint_impl {
|
||||
/// wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_add(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_add(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_add(self, rhs)
|
||||
}
|
||||
@ -1016,7 +1016,7 @@ macro_rules! uint_impl {
|
||||
/// wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_sub(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_sub(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_sub(self, rhs)
|
||||
}
|
||||
@ -1026,7 +1026,7 @@ macro_rules! uint_impl {
|
||||
/// other`, wrapping around at the boundary of the type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn wrapping_mul(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_mul(self, rhs: Self) -> Self {
|
||||
unsafe {
|
||||
intrinsics::overflowing_mul(self, rhs)
|
||||
}
|
||||
@ -1043,7 +1043,7 @@ macro_rules! uint_impl {
|
||||
/// itself..
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_div(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_div(self, rhs: Self) -> Self {
|
||||
self.overflowing_div(rhs).0
|
||||
}
|
||||
|
||||
@ -1056,7 +1056,7 @@ macro_rules! uint_impl {
|
||||
/// minimal value). In such a case, this function returns `0`.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_rem(self, rhs: $T) -> $T {
|
||||
pub fn wrapping_rem(self, rhs: Self) -> Self {
|
||||
self.overflowing_rem(rhs).0
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ macro_rules! uint_impl {
|
||||
/// a case, this function returns `MIN` itself.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_neg(self) -> $T {
|
||||
pub fn wrapping_neg(self) -> Self {
|
||||
self.overflowing_neg().0
|
||||
}
|
||||
|
||||
@ -1079,7 +1079,7 @@ macro_rules! uint_impl {
|
||||
/// would cause the shift to exceed the bitwidth of the type.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_shl(self, rhs: u32) -> $T {
|
||||
pub fn wrapping_shl(self, rhs: u32) -> Self {
|
||||
self.overflowing_shl(rhs).0
|
||||
}
|
||||
|
||||
@ -1088,7 +1088,7 @@ macro_rules! uint_impl {
|
||||
/// would cause the shift to exceed the bitwidth of the type.
|
||||
#[unstable(feature = "core", since = "1.0.0")]
|
||||
#[inline(always)]
|
||||
pub fn wrapping_shr(self, rhs: u32) -> $T {
|
||||
pub fn wrapping_shr(self, rhs: u32) -> Self {
|
||||
self.overflowing_shr(rhs).0
|
||||
}
|
||||
|
||||
@ -1101,9 +1101,9 @@ macro_rules! uint_impl {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn pow(self, mut exp: u32) -> $T {
|
||||
pub fn pow(self, mut exp: u32) -> Self {
|
||||
let mut base = self;
|
||||
let mut acc = <$T as One>::one();
|
||||
let mut acc = Self::one();
|
||||
|
||||
let mut prev_base = self;
|
||||
let mut base_oflo = false;
|
||||
@ -1131,17 +1131,17 @@ macro_rules! uint_impl {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_power_of_two(self) -> bool {
|
||||
(self.wrapping_sub(<$T as One>::one())) & self == <$T as Zero>::zero() &&
|
||||
!(self == <$T as Zero>::zero())
|
||||
(self.wrapping_sub(Self::one())) & self == Self::zero() &&
|
||||
!(self == Self::zero())
|
||||
}
|
||||
|
||||
/// Returns the smallest power of two greater than or equal to `self`.
|
||||
/// Unspecified behavior on overflow.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn next_power_of_two(self) -> $T {
|
||||
let bits = size_of::<$T>() * 8;
|
||||
let one: $T = <$T as One>::one();
|
||||
pub fn next_power_of_two(self) -> Self {
|
||||
let bits = size_of::<Self>() * 8;
|
||||
let one: Self = Self::one();
|
||||
one << ((bits - self.wrapping_sub(one).leading_zeros() as usize) % bits)
|
||||
}
|
||||
|
||||
@ -1149,7 +1149,7 @@ macro_rules! uint_impl {
|
||||
/// the next power of two is greater than the type's maximum value,
|
||||
/// `None` is returned, otherwise the power of two is wrapped in `Some`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn checked_next_power_of_two(self) -> Option<$T> {
|
||||
pub fn checked_next_power_of_two(self) -> Option<Self> {
|
||||
let npot = self.next_power_of_two();
|
||||
if npot >= self {
|
||||
Some(npot)
|
||||
@ -1162,7 +1162,7 @@ macro_rules! uint_impl {
|
||||
|
||||
#[lang = "u8"]
|
||||
impl u8 {
|
||||
uint_impl! { u8 = u8, 8,
|
||||
uint_impl! { u8, 8,
|
||||
intrinsics::ctpop8,
|
||||
intrinsics::ctlz8,
|
||||
intrinsics::cttz8,
|
||||
@ -1174,7 +1174,7 @@ impl u8 {
|
||||
|
||||
#[lang = "u16"]
|
||||
impl u16 {
|
||||
uint_impl! { u16 = u16, 16,
|
||||
uint_impl! { u16, 16,
|
||||
intrinsics::ctpop16,
|
||||
intrinsics::ctlz16,
|
||||
intrinsics::cttz16,
|
||||
@ -1186,7 +1186,7 @@ impl u16 {
|
||||
|
||||
#[lang = "u32"]
|
||||
impl u32 {
|
||||
uint_impl! { u32 = u32, 32,
|
||||
uint_impl! { u32, 32,
|
||||
intrinsics::ctpop32,
|
||||
intrinsics::ctlz32,
|
||||
intrinsics::cttz32,
|
||||
@ -1199,7 +1199,7 @@ impl u32 {
|
||||
|
||||
#[lang = "u64"]
|
||||
impl u64 {
|
||||
uint_impl! { u64 = u64, 64,
|
||||
uint_impl! { u64, 64,
|
||||
intrinsics::ctpop64,
|
||||
intrinsics::ctlz64,
|
||||
intrinsics::cttz64,
|
||||
@ -1212,7 +1212,7 @@ impl u64 {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
uint_impl! { usize = u32, 32,
|
||||
uint_impl! { u32, 32,
|
||||
intrinsics::ctpop32,
|
||||
intrinsics::ctlz32,
|
||||
intrinsics::cttz32,
|
||||
@ -1225,7 +1225,7 @@ impl usize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
uint_impl! { usize = u64, 64,
|
||||
uint_impl! { u64, 64,
|
||||
intrinsics::ctpop64,
|
||||
intrinsics::ctlz64,
|
||||
intrinsics::cttz64,
|
||||
@ -1362,9 +1362,9 @@ pub trait Float {
|
||||
}
|
||||
|
||||
macro_rules! from_str_float_impl {
|
||||
($T:ident) => {
|
||||
($t:ty) => {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl FromStr for $T {
|
||||
impl FromStr for $t {
|
||||
type Err = ParseFloatError;
|
||||
|
||||
/// Converts a string in base 10 to a float.
|
||||
@ -1395,8 +1395,8 @@ macro_rules! from_str_float_impl {
|
||||
/// number represented by `src`.
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
fn from_str(src: &str) -> Result<$T, ParseFloatError> {
|
||||
$T::from_str_radix(src, 10)
|
||||
fn from_str(src: &str) -> Result<Self, ParseFloatError> {
|
||||
Self::from_str_radix(src, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1405,12 +1405,12 @@ from_str_float_impl!(f32);
|
||||
from_str_float_impl!(f64);
|
||||
|
||||
macro_rules! from_str_radix_int_impl {
|
||||
($($T:ident)*) => {$(
|
||||
($($t:ty)*) => {$(
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow(deprecated)]
|
||||
impl FromStr for $T {
|
||||
impl FromStr for $t {
|
||||
type Err = ParseIntError;
|
||||
fn from_str(src: &str) -> Result<$T, ParseIntError> {
|
||||
fn from_str(src: &str) -> Result<Self, ParseIntError> {
|
||||
from_str_radix(src, 10)
|
||||
}
|
||||
}
|
||||
@ -1428,17 +1428,17 @@ trait FromStrRadixHelper: PartialOrd + Copy {
|
||||
}
|
||||
|
||||
macro_rules! doit {
|
||||
($($t:ident)*) => ($(impl FromStrRadixHelper for $t {
|
||||
fn min_value() -> Self { <$t>::min_value() }
|
||||
fn from_u32(u: u32) -> Self { u as $t }
|
||||
($($t:ty)*) => ($(impl FromStrRadixHelper for $t {
|
||||
fn min_value() -> Self { Self::min_value() }
|
||||
fn from_u32(u: u32) -> Self { u as Self }
|
||||
fn checked_mul(&self, other: u32) -> Option<Self> {
|
||||
<$t>::checked_mul(*self, other as $t)
|
||||
Self::checked_mul(*self, other as Self)
|
||||
}
|
||||
fn checked_sub(&self, other: u32) -> Option<Self> {
|
||||
<$t>::checked_sub(*self, other as $t)
|
||||
Self::checked_sub(*self, other as Self)
|
||||
}
|
||||
fn checked_add(&self, other: u32) -> Option<Self> {
|
||||
<$t>::checked_add(*self, other as $t)
|
||||
Self::checked_add(*self, other as Self)
|
||||
}
|
||||
})*)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use metadata::decoder;
|
||||
use metadata::loader;
|
||||
use metadata::loader::CratePaths;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::fs;
|
||||
@ -376,14 +377,13 @@ impl<'a> CrateReader<'a> {
|
||||
let loader::Library { dylib, rlib, metadata } = lib;
|
||||
|
||||
let cnum_map = self.resolve_crate_deps(root, metadata.as_slice(), span);
|
||||
let codemap_import_info = import_codemap(self.sess.codemap(), &metadata);
|
||||
|
||||
let cmeta = Rc::new( cstore::crate_metadata {
|
||||
name: name.to_string(),
|
||||
data: metadata,
|
||||
cnum_map: cnum_map,
|
||||
cnum: cnum,
|
||||
codemap_import_info: codemap_import_info,
|
||||
codemap_import_info: RefCell::new(vec![]),
|
||||
span: span,
|
||||
});
|
||||
|
||||
@ -616,9 +616,9 @@ impl<'a> CrateReader<'a> {
|
||||
/// file they represent, just information about length, line breaks, and
|
||||
/// multibyte characters. This information is enough to generate valid debuginfo
|
||||
/// for items inlined from other crates.
|
||||
fn import_codemap(local_codemap: &codemap::CodeMap,
|
||||
metadata: &MetadataBlob)
|
||||
-> Vec<cstore::ImportedFileMap> {
|
||||
pub fn import_codemap(local_codemap: &codemap::CodeMap,
|
||||
metadata: &MetadataBlob)
|
||||
-> Vec<cstore::ImportedFileMap> {
|
||||
let external_codemap = decoder::get_imported_filemaps(metadata.as_slice());
|
||||
|
||||
let imported_filemaps = external_codemap.into_iter().map(|filemap_to_import| {
|
||||
|
@ -18,12 +18,11 @@ pub use self::LinkagePreference::*;
|
||||
pub use self::NativeLibraryKind::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use metadata::decoder;
|
||||
use metadata::loader;
|
||||
use metadata::{creader, decoder, loader};
|
||||
use session::search_paths::PathKind;
|
||||
use util::nodemap::{FnvHashMap, NodeMap};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{RefCell, Ref};
|
||||
use std::rc::Rc;
|
||||
use std::path::PathBuf;
|
||||
use flate::Bytes;
|
||||
@ -58,7 +57,7 @@ pub struct crate_metadata {
|
||||
pub data: MetadataBlob,
|
||||
pub cnum_map: cnum_map,
|
||||
pub cnum: ast::CrateNum,
|
||||
pub codemap_import_info: Vec<ImportedFileMap>,
|
||||
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
|
||||
pub span: codemap::Span,
|
||||
}
|
||||
|
||||
@ -240,6 +239,20 @@ impl crate_metadata {
|
||||
pub fn data<'a>(&'a self) -> &'a [u8] { self.data.as_slice() }
|
||||
pub fn name(&self) -> String { decoder::get_crate_name(self.data()) }
|
||||
pub fn hash(&self) -> Svh { decoder::get_crate_hash(self.data()) }
|
||||
pub fn imported_filemaps<'a>(&'a self, codemap: &codemap::CodeMap)
|
||||
-> Ref<'a, Vec<ImportedFileMap>> {
|
||||
let filemaps = self.codemap_import_info.borrow();
|
||||
if filemaps.is_empty() {
|
||||
drop(filemaps);
|
||||
let filemaps = creader::import_codemap(codemap, &self.data);
|
||||
|
||||
// This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref.
|
||||
*self.codemap_import_info.borrow_mut() = filemaps;
|
||||
self.codemap_import_info.borrow()
|
||||
} else {
|
||||
filemaps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetadataBlob {
|
||||
|
@ -233,8 +233,6 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
|
||||
/// codemap as a side-effect of creating the crate_metadata's
|
||||
/// `codemap_import_info`.
|
||||
pub fn tr_span(&self, span: Span) -> Span {
|
||||
let imported_filemaps = &self.cdata.codemap_import_info[..];
|
||||
|
||||
let span = if span.lo > span.hi {
|
||||
// Currently macro expansion sometimes produces invalid Span values
|
||||
// where lo > hi. In order not to crash the compiler when trying to
|
||||
@ -248,16 +246,18 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
|
||||
span
|
||||
};
|
||||
|
||||
let filemap_index = {
|
||||
let imported_filemaps = self.cdata.imported_filemaps(self.tcx.sess.codemap());
|
||||
let filemap = {
|
||||
// Optimize for the case that most spans within a translated item
|
||||
// originate from the same filemap.
|
||||
let last_filemap_index = self.last_filemap_index.get();
|
||||
let last_filemap = &imported_filemaps[last_filemap_index];
|
||||
|
||||
if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
|
||||
span.lo <= imported_filemaps[last_filemap_index].original_end_pos &&
|
||||
span.hi >= imported_filemaps[last_filemap_index].original_start_pos &&
|
||||
span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
|
||||
last_filemap_index
|
||||
if span.lo >= last_filemap.original_start_pos &&
|
||||
span.lo <= last_filemap.original_end_pos &&
|
||||
span.hi >= last_filemap.original_start_pos &&
|
||||
span.hi <= last_filemap.original_end_pos {
|
||||
last_filemap
|
||||
} else {
|
||||
let mut a = 0;
|
||||
let mut b = imported_filemaps.len();
|
||||
@ -272,14 +272,14 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
|
||||
}
|
||||
|
||||
self.last_filemap_index.set(a);
|
||||
a
|
||||
&imported_filemaps[a]
|
||||
}
|
||||
};
|
||||
|
||||
let lo = (span.lo - imported_filemaps[filemap_index].original_start_pos) +
|
||||
imported_filemaps[filemap_index].translated_filemap.start_pos;
|
||||
let hi = (span.hi - imported_filemaps[filemap_index].original_start_pos) +
|
||||
imported_filemaps[filemap_index].translated_filemap.start_pos;
|
||||
let lo = (span.lo - filemap.original_start_pos) +
|
||||
filemap.translated_filemap.start_pos;
|
||||
let hi = (span.hi - filemap.original_start_pos) +
|
||||
filemap.translated_filemap.start_pos;
|
||||
|
||||
codemap::mk_sp(lo, hi)
|
||||
}
|
||||
|
@ -443,6 +443,8 @@ a {
|
||||
.content .search-results td:first-child { padding-right: 0; }
|
||||
.content .search-results td:first-child a { padding-right: 10px; }
|
||||
|
||||
tr.result span.primitive::after { content: ' (primitive type)'; font-style: italic; }
|
||||
|
||||
#help {
|
||||
background: #e9e9e9;
|
||||
border-radius: 4px;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var resizeTimeout, interval;
|
||||
|
||||
// This mapping table should match the discriminants of
|
||||
// `rustdoc::html::item_type::ItemType` type in Rust.
|
||||
@ -37,6 +36,9 @@
|
||||
"constant",
|
||||
"associatedconstant"];
|
||||
|
||||
// used for special search precedence
|
||||
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
|
||||
|
||||
$('.js-only').removeClass('js-only');
|
||||
|
||||
function getQueryStringParams() {
|
||||
@ -64,7 +66,7 @@
|
||||
if ($('#' + from).length === 0) {
|
||||
return;
|
||||
}
|
||||
if (ev === null) $('#' + from)[0].scrollIntoView();
|
||||
if (ev === null) { $('#' + from)[0].scrollIntoView(); };
|
||||
$('.line-numbers span').removeClass('line-highlighted');
|
||||
for (i = from; i <= to; ++i) {
|
||||
$('#' + i).addClass('line-highlighted');
|
||||
@ -74,7 +76,7 @@
|
||||
highlightSourceLines(null);
|
||||
$(window).on('hashchange', highlightSourceLines);
|
||||
|
||||
$(document).on('keyup', function(e) {
|
||||
$(document).on('keyup', function handleKeyboardShortcut(e) {
|
||||
if (document.activeElement.tagName === 'INPUT') {
|
||||
return;
|
||||
}
|
||||
@ -133,29 +135,28 @@
|
||||
return function(s1, s2) {
|
||||
if (s1 === s2) {
|
||||
return 0;
|
||||
} else {
|
||||
var s1_len = s1.length, s2_len = s2.length;
|
||||
if (s1_len && s2_len) {
|
||||
var i1 = 0, i2 = 0, a, b, c, c2, row = row2;
|
||||
while (i1 < s1_len)
|
||||
row[i1] = ++i1;
|
||||
while (i2 < s2_len) {
|
||||
c2 = s2.charCodeAt(i2);
|
||||
a = i2;
|
||||
++i2;
|
||||
b = i2;
|
||||
for (i1 = 0; i1 < s1_len; ++i1) {
|
||||
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
|
||||
a = row[i1];
|
||||
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
|
||||
row[i1] = b;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
} else {
|
||||
return s1_len + s2_len;
|
||||
}
|
||||
}
|
||||
var s1_len = s1.length, s2_len = s2.length;
|
||||
if (s1_len && s2_len) {
|
||||
var i1 = 0, i2 = 0, a, b, c, c2, row = row2;
|
||||
while (i1 < s1_len) {
|
||||
row[i1] = ++i1;
|
||||
}
|
||||
while (i2 < s2_len) {
|
||||
c2 = s2.charCodeAt(i2);
|
||||
a = i2;
|
||||
++i2;
|
||||
b = i2;
|
||||
for (i1 = 0; i1 < s1_len; ++i1) {
|
||||
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
|
||||
a = row[i1];
|
||||
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
|
||||
row[i1] = b;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
return s1_len + s2_len;
|
||||
};
|
||||
})();
|
||||
|
||||
@ -187,7 +188,7 @@
|
||||
results = [],
|
||||
split = valLower.split("::");
|
||||
|
||||
//remove empty keywords
|
||||
// remove empty keywords
|
||||
for (var j = 0; j < split.length; ++j) {
|
||||
split[j].toLowerCase();
|
||||
if (split[j] === "") {
|
||||
@ -286,58 +287,63 @@
|
||||
return [];
|
||||
}
|
||||
|
||||
results.sort(function(aaa, bbb) {
|
||||
results.sort(function sortResults(aaa, bbb) {
|
||||
var a, b;
|
||||
|
||||
// Sort by non levenshtein results and then levenshtein results by the distance
|
||||
// (less changes required to match means higher rankings)
|
||||
a = (aaa.lev);
|
||||
b = (bbb.lev);
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by crate (non-current crate goes later)
|
||||
a = (aaa.item.crate !== window.currentCrate);
|
||||
b = (bbb.item.crate !== window.currentCrate);
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by exact match (mismatch goes later)
|
||||
a = (aaa.word !== valLower);
|
||||
b = (bbb.word !== valLower);
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by item name length (longer goes later)
|
||||
a = aaa.word.length;
|
||||
b = bbb.word.length;
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by item name (lexicographically larger goes later)
|
||||
a = aaa.word;
|
||||
b = bbb.word;
|
||||
if (a !== b) return (a > b ? +1 : -1);
|
||||
if (a !== b) { return (a > b ? +1 : -1); }
|
||||
|
||||
// sort by index of keyword in item name (no literal occurrence goes later)
|
||||
a = (aaa.index < 0);
|
||||
b = (bbb.index < 0);
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
// (later literal occurrence, if any, goes later)
|
||||
a = aaa.index;
|
||||
b = bbb.index;
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// special precedence for primitive pages
|
||||
if ((aaa.item.ty === TY_PRIMITIVE) && (bbb.item.ty !== TY_PRIMITIVE)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// sort by description (no description goes later)
|
||||
a = (aaa.item.desc === '');
|
||||
b = (bbb.item.desc === '');
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by type (later occurrence in `itemTypes` goes later)
|
||||
a = aaa.item.ty;
|
||||
b = bbb.item.ty;
|
||||
if (a !== b) return a - b;
|
||||
if (a !== b) { return a - b; }
|
||||
|
||||
// sort by path (lexicographically larger goes later)
|
||||
a = aaa.item.path;
|
||||
b = bbb.item.path;
|
||||
if (a !== b) return (a > b ? +1 : -1);
|
||||
if (a !== b) { return (a > b ? +1 : -1); }
|
||||
|
||||
// que sera, sera
|
||||
return 0;
|
||||
@ -388,7 +394,7 @@
|
||||
* @return {[boolean]} [Whether the result is valid or not]
|
||||
*/
|
||||
function validateResult(name, path, keys, parent) {
|
||||
for (var i=0; i < keys.length; ++i) {
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
// each check is for validation so we negate the conditions and invalidate
|
||||
if (!(
|
||||
// check for an exact name match
|
||||
@ -423,7 +429,7 @@
|
||||
raw: raw,
|
||||
query: query,
|
||||
type: type,
|
||||
id: query + type,
|
||||
id: query + type
|
||||
};
|
||||
}
|
||||
|
||||
@ -432,7 +438,7 @@
|
||||
|
||||
$results.on('click', function() {
|
||||
var dst = $(this).find('a')[0];
|
||||
if (window.location.pathname == dst.pathname) {
|
||||
if (window.location.pathname === dst.pathname) {
|
||||
$('#search').addClass('hidden');
|
||||
$('#main').removeClass('hidden');
|
||||
document.location.href = dst.href;
|
||||
@ -595,7 +601,7 @@
|
||||
|
||||
function itemTypeFromName(typename) {
|
||||
for (var i = 0; i < itemTypes.length; ++i) {
|
||||
if (itemTypes[i] === typename) return i;
|
||||
if (itemTypes[i] === typename) { return i; }
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -604,7 +610,7 @@
|
||||
searchIndex = [];
|
||||
var searchWords = [];
|
||||
for (var crate in rawSearchIndex) {
|
||||
if (!rawSearchIndex.hasOwnProperty(crate)) { continue }
|
||||
if (!rawSearchIndex.hasOwnProperty(crate)) { continue; }
|
||||
|
||||
// an array of [(Number) item type,
|
||||
// (String) name,
|
||||
@ -690,32 +696,31 @@
|
||||
}
|
||||
|
||||
function plainSummaryLine(markdown) {
|
||||
var str = markdown.replace(/\n/g, ' ')
|
||||
str = str.replace(/'/g, "\'")
|
||||
str = str.replace(/^#+? (.+?)/, "$1")
|
||||
str = str.replace(/\[(.*?)\]\(.*?\)/g, "$1")
|
||||
str = str.replace(/\[(.*?)\]\[.*?\]/g, "$1")
|
||||
return str;
|
||||
markdown.replace(/\n/g, ' ')
|
||||
.replace(/'/g, "\'")
|
||||
.replace(/^#+? (.+?)/, "$1")
|
||||
.replace(/\[(.*?)\]\(.*?\)/g, "$1")
|
||||
.replace(/\[(.*?)\]\[.*?\]/g, "$1");
|
||||
}
|
||||
|
||||
index = buildIndex(rawSearchIndex);
|
||||
startSearch();
|
||||
|
||||
// Draw a convenient sidebar of known crates if we have a listing
|
||||
if (rootPath == '../') {
|
||||
if (rootPath === '../') {
|
||||
var sidebar = $('.sidebar');
|
||||
var div = $('<div>').attr('class', 'block crate');
|
||||
div.append($('<h2>').text('Crates'));
|
||||
|
||||
var crates = [];
|
||||
for (var crate in rawSearchIndex) {
|
||||
if (!rawSearchIndex.hasOwnProperty(crate)) { continue }
|
||||
if (!rawSearchIndex.hasOwnProperty(crate)) { continue; }
|
||||
crates.push(crate);
|
||||
}
|
||||
crates.sort();
|
||||
for (var i = 0; i < crates.length; ++i) {
|
||||
var klass = 'crate';
|
||||
if (crates[i] == window.currentCrate) {
|
||||
if (crates[i] === window.currentCrate) {
|
||||
klass += ' current';
|
||||
}
|
||||
if (rawSearchIndex[crates[i]].items[0]) {
|
||||
@ -738,7 +743,7 @@
|
||||
|
||||
function block(shortty, longty) {
|
||||
var filtered = items[shortty];
|
||||
if (!filtered) return;
|
||||
if (!filtered) { return; }
|
||||
|
||||
var div = $('<div>').attr('class', 'block ' + shortty);
|
||||
div.append($('<h2>').text(longty));
|
||||
@ -749,7 +754,7 @@
|
||||
var desc = item[1]; // can be null
|
||||
|
||||
var klass = shortty;
|
||||
if (name === current.name && shortty == current.ty) {
|
||||
if (name === current.name && shortty === current.ty) {
|
||||
klass += ' current';
|
||||
}
|
||||
var path;
|
||||
@ -779,7 +784,7 @@
|
||||
var list = $('#implementors-list');
|
||||
var libs = Object.getOwnPropertyNames(imp);
|
||||
for (var i = 0; i < libs.length; ++i) {
|
||||
if (libs[i] == currentCrate) continue;
|
||||
if (libs[i] === currentCrate) { continue; }
|
||||
var structs = imp[libs[i]];
|
||||
for (var j = 0; j < structs.length; ++j) {
|
||||
var code = $('<code>').append(structs[j]);
|
||||
@ -811,11 +816,10 @@
|
||||
if (sectionIsCollapsed) {
|
||||
// button will expand the section
|
||||
return "+";
|
||||
} else {
|
||||
// button will collapse the section
|
||||
// note that this text is also set in the HTML template in render.rs
|
||||
return "\u2212"; // "\u2212" is '−' minus sign
|
||||
}
|
||||
// button will collapse the section
|
||||
// note that this text is also set in the HTML template in render.rs
|
||||
return "\u2212"; // "\u2212" is '−' minus sign
|
||||
}
|
||||
|
||||
$("#toggle-all-docs").on("click", function() {
|
||||
@ -847,12 +851,12 @@
|
||||
}
|
||||
if (relatedDoc.is(".docblock")) {
|
||||
if (relatedDoc.is(":visible")) {
|
||||
relatedDoc.slideUp({duration:'fast', easing:'linear'});
|
||||
relatedDoc.slideUp({duration: 'fast', easing: 'linear'});
|
||||
toggle.parent(".toggle-wrapper").addClass("collapsed");
|
||||
toggle.children(".inner").text(labelForToggleButton(true));
|
||||
toggle.children(".toggle-label").fadeIn();
|
||||
} else {
|
||||
relatedDoc.slideDown({duration:'fast', easing:'linear'});
|
||||
relatedDoc.slideDown({duration: 'fast', easing: 'linear'});
|
||||
toggle.parent(".toggle-wrapper").removeClass("collapsed");
|
||||
toggle.children(".inner").text(labelForToggleButton(false));
|
||||
toggle.children(".toggle-label").hide();
|
||||
@ -877,7 +881,7 @@
|
||||
$('<span/>', {'class': 'toggle-label'})
|
||||
.css('display', 'none')
|
||||
.html(' Expand description'));
|
||||
var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
|
||||
var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
|
||||
$("#main > .docblock").before(wrapper);
|
||||
});
|
||||
|
||||
@ -894,7 +898,7 @@
|
||||
}
|
||||
|
||||
return function(ev) {
|
||||
var cur_id = parseInt(ev.target.id);
|
||||
var cur_id = parseInt(ev.target.id, 10);
|
||||
|
||||
if (ev.shiftKey && prev_id) {
|
||||
if (prev_id > cur_id) {
|
||||
|
@ -26,7 +26,7 @@
|
||||
//!
|
||||
//! ## What is in the standard library
|
||||
//!
|
||||
//! The standard library is minimal, a set of battle-tested
|
||||
//! The standard library is a set of minimal, battle-tested
|
||||
//! core types and shared abstractions for the [broader Rust
|
||||
//! ecosystem](https://crates.io) to build on.
|
||||
//!
|
||||
|
@ -154,18 +154,18 @@ pub trait MultiItemDecorator {
|
||||
ecx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable));
|
||||
}
|
||||
|
||||
impl<F> MultiItemDecorator for F
|
||||
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, Annotatable, &mut FnMut(Annotatable))
|
||||
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, &mut FnMut(Annotatable))
|
||||
{
|
||||
fn expand(&self,
|
||||
ecx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable)) {
|
||||
(*self)(ecx, sp, meta_item, item, push)
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use ext::deriving::generic::ty::*;
|
||||
pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
_: &MetaItem,
|
||||
_: Annotatable,
|
||||
_: &Annotatable,
|
||||
_: &mut FnMut(Annotatable))
|
||||
{
|
||||
cx.span_err(span, "this unsafe trait should be implemented explicitly");
|
||||
@ -26,7 +26,7 @@ pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
|
||||
pub fn expand_deriving_copy(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let path = Path::new(vec![
|
||||
@ -45,5 +45,5 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push);
|
||||
trait_def.expand(cx, mitem, item, push);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_clone(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let inline = cx.meta_word(span, InternedString::new("inline"));
|
||||
@ -48,7 +48,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn cs_clone(
|
||||
|
@ -20,7 +20,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_eq(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
fn cs_total_eq_assert(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
|
||||
@ -67,5 +67,5 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
|
||||
),
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_ord(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let inline = cx.meta_word(span, InternedString::new("inline"));
|
||||
@ -49,7 +49,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
// structures are equal if all fields are equal, and non equal, if
|
||||
@ -91,5 +91,5 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
|
||||
),
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
macro_rules! md {
|
||||
@ -82,7 +82,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
|
||||
],
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -24,7 +24,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
expand_deriving_decodable_imp(cx, span, mitem, item, push, "rustc_serialize")
|
||||
@ -33,7 +33,7 @@ pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt,
|
||||
pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
expand_deriving_decodable_imp(cx, span, mitem, item, push, "serialize")
|
||||
@ -42,7 +42,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
|
||||
fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable),
|
||||
krate: &'static str)
|
||||
{
|
||||
@ -88,7 +88,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
|
@ -20,7 +20,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_default(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let inline = cx.meta_word(span, InternedString::new("inline"));
|
||||
@ -47,7 +47,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
|
||||
),
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
|
||||
|
@ -100,7 +100,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
expand_deriving_encodable_imp(cx, span, mitem, item, push, "rustc_serialize")
|
||||
@ -109,7 +109,7 @@ pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt,
|
||||
pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
expand_deriving_encodable_imp(cx, span, mitem, item, push, "serialize")
|
||||
@ -118,7 +118,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
|
||||
fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable),
|
||||
krate: &'static str)
|
||||
{
|
||||
@ -164,7 +164,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
|
@ -19,7 +19,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_hash(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
|
||||
@ -53,7 +53,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
hash_trait_def.expand(cx, mitem, &item, push);
|
||||
hash_trait_def.expand(cx, mitem, item, push);
|
||||
}
|
||||
|
||||
fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
|
||||
|
@ -134,7 +134,7 @@ macro_rules! derive_traits {
|
||||
ecx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
mitem: &MetaItem,
|
||||
annotatable: Annotatable,
|
||||
annotatable: &Annotatable,
|
||||
push: &mut FnMut(Annotatable)) {
|
||||
warn_if_deprecated(ecx, sp, $name);
|
||||
$func(ecx, sp, mitem, annotatable, push);
|
||||
|
@ -21,7 +21,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let inline = cx.meta_word(span, InternedString::new("inline"));
|
||||
@ -69,7 +69,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
|
||||
|
@ -21,7 +21,7 @@ use ptr::P;
|
||||
pub fn expand_deriving_show(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
// &mut ::std::fmt::Formatter
|
||||
@ -50,7 +50,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt,
|
||||
],
|
||||
associated_types: Vec::new(),
|
||||
};
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
/// We use the debug builders to do the heavy lifting here
|
||||
|
@ -1212,7 +1212,7 @@ fn expand_decorators(a: Annotatable,
|
||||
dec.expand(fld.cx,
|
||||
attr.span,
|
||||
&attr.node.value,
|
||||
a.clone(),
|
||||
&a,
|
||||
&mut |ann| items.push(ann));
|
||||
decorator_items.extend(items.into_iter()
|
||||
.flat_map(|ann| expand_annotatable(ann, fld).into_iter()));
|
||||
|
@ -37,7 +37,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||
fn expand(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &ast::MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable)) {
|
||||
let trait_def = TraitDef {
|
||||
span: span,
|
||||
@ -71,5 +71,5 @@ fn expand(cx: &mut ExtCtxt,
|
||||
],
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||
fn expand(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &ast::MetaItem,
|
||||
item: Annotatable,
|
||||
item: &Annotatable,
|
||||
push: &mut FnMut(Annotatable)) {
|
||||
let trait_def = TraitDef {
|
||||
span: span,
|
||||
@ -62,7 +62,7 @@ fn expand(cx: &mut ExtCtxt,
|
||||
],
|
||||
};
|
||||
|
||||
trait_def.expand(cx, mitem, &item, push)
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
// Mostly copied from syntax::ext::deriving::hash
|
||||
|
@ -108,7 +108,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
||||
fn expand_duplicate(cx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
mi: &MetaItem,
|
||||
it: Annotatable,
|
||||
it: &Annotatable,
|
||||
push: &mut FnMut(Annotatable))
|
||||
{
|
||||
let copy_name = match mi.node {
|
||||
|
Loading…
Reference in New Issue
Block a user