Skip to content

Commit edecc57

Browse files
authored
Auto merge of #35053 - steveklabnik:rollup, r=steveklabnik
Rollup of 15 pull requests - Successful merges: #34461, #34609, #34732, #34850, #34935, #34974, #34990, #34995, #35001, #35009, #35010, #35019, #35028, #35029, #35043 - Failed merges:
2 parents b541f5f + d64de04 commit edecc57

File tree

13 files changed

+624
-415
lines changed

13 files changed

+624
-415
lines changed

src/doc/book/syntax-index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
* `|` (`|…| expr`): closures. See [Closures].
9595
* `|=` (`var |= expr`): bitwise or & assignment. Overloadable (`BitOrAssign`).
9696
* `||` (`expr || expr`): logical or.
97-
* `_`: "ignored" pattern binding. See [Patterns (Ignoring bindings)].
97+
* `_`: "ignored" pattern binding (see [Patterns (Ignoring bindings)]). Also used to make integer-literals readable (see [Reference (Integer literals)]).
9898

9999
## Other Syntax
100100

@@ -231,6 +231,7 @@
231231
[Primitive Types (Tuples)]: primitive-types.html#tuples
232232
[Raw Pointers]: raw-pointers.html
233233
[Reference (Byte String Literals)]: ../reference.html#byte-string-literals
234+
[Reference (Integer literals)]: ../reference.html#integer-literals
234235
[Reference (Raw Byte String Literals)]: ../reference.html#raw-byte-string-literals
235236
[Reference (Raw String Literals)]: ../reference.html#raw-string-literals
236237
[References and Borrowing]: references-and-borrowing.html

src/doc/book/trait-objects.md

-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ dispatch with trait objects by casting:
123123
# trait Foo { fn method(&self) -> String; }
124124
# impl Foo for u8 { fn method(&self) -> String { format!("u8: {}", *self) } }
125125
# impl Foo for String { fn method(&self) -> String { format!("string: {}", *self) } }
126-
127126
fn do_something(x: &Foo) {
128127
x.method();
129128
}
@@ -140,7 +139,6 @@ or by coercing:
140139
# trait Foo { fn method(&self) -> String; }
141140
# impl Foo for u8 { fn method(&self) -> String { format!("u8: {}", *self) } }
142141
# impl Foo for String { fn method(&self) -> String { format!("string: {}", *self) } }
143-
144142
fn do_something(x: &Foo) {
145143
x.method();
146144
}

src/doc/nomicon/phantom-data.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct Vec<T> {
5050
}
5151
```
5252

53-
Unlike the previous example it *appears* that everything is exactly as we
53+
Unlike the previous example, it *appears* that everything is exactly as we
5454
want. Every generic argument to Vec shows up in at least one field.
5555
Good to go!
5656

@@ -84,4 +84,3 @@ standard library made a utility for itself called `Unique<T>` which:
8484
* includes a `PhantomData<T>`
8585
* auto-derives Send/Sync as if T was contained
8686
* marks the pointer as NonZero for the null-pointer optimization
87-

src/doc/reference.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -1653,14 +1653,43 @@ the Rust ABI and the foreign ABI.
16531653
A number of [attributes](#ffi-attributes) control the behavior of external blocks.
16541654

16551655
By default external blocks assume that the library they are calling uses the
1656-
standard C "cdecl" ABI. Other ABIs may be specified using an `abi` string, as
1657-
shown here:
1656+
standard C ABI on the specific platform. Other ABIs may be specified using an
1657+
`abi` string, as shown here:
16581658

16591659
```ignore
16601660
// Interface to the Windows API
16611661
extern "stdcall" { }
16621662
```
16631663

1664+
There are three ABI strings which are cross-platform, and which all compilers
1665+
are guaranteed to support:
1666+
1667+
* `extern "Rust"` -- The default ABI when you write a normal `fn foo()` in any
1668+
Rust code.
1669+
* `extern "C"` -- This is the same as `extern fn foo()`; whatever the default
1670+
your C compiler supports.
1671+
* `extern "system"` -- Usually the same as `extern "C"`, except on Win32, in
1672+
which case it's `"stdcall"`, or what you should use to link to the Windows API
1673+
itself
1674+
1675+
There are also some platform-specific ABI strings:
1676+
1677+
* `extern "cdecl"` -- The default for x86\_32 C code.
1678+
* `extern "stdcall"` -- The default for the Win32 API on x86\_32.
1679+
* `extern "win64"` -- The default for C code on x86\_64 Windows.
1680+
* `extern "aapcs"` -- The default for ARM.
1681+
* `extern "fastcall"` -- The `fastcall` ABI -- corresponds to MSVC's
1682+
`__fastcall` and GCC and clang's `__attribute__((fastcall))`
1683+
* `extern "vectorcall"` -- The `vectorcall` ABI -- corresponds to MSVC's
1684+
`__vectorcall` and clang's `__attribute__((vectorcall))`
1685+
1686+
Finally, there are some rustc-specific ABI strings:
1687+
1688+
* `extern "rust-intrinsic"` -- The ABI of rustc intrinsics.
1689+
* `extern "rust-call"` -- The ABI of the Fn::call trait functions.
1690+
* `extern "platform-intrinsic"` -- Specific platform intrinsics -- like, for
1691+
example, `sqrt` -- have this ABI. You should never have to deal with it.
1692+
16641693
The `link` attribute allows the name of the library to be specified. When
16651694
specified the compiler will attempt to link against the native library of the
16661695
specified name.

src/libcollections/slice.rs

+31-6
Original file line numberDiff line numberDiff line change
@@ -691,15 +691,40 @@ impl<T> [T] {
691691
///
692692
/// # Examples
693693
///
694-
/// Print the slice split by numbers divisible by 3 (i.e. `[10, 40]`,
695-
/// `[20]`, `[50]`):
694+
/// ```
695+
/// let slice = [10, 40, 33, 20];
696+
/// let mut iter = slice.split(|num| num % 3 == 0);
696697
///
698+
/// assert_eq!(iter.next().unwrap(), &[10, 40]);
699+
/// assert_eq!(iter.next().unwrap(), &[20]);
700+
/// assert!(iter.next().is_none());
697701
/// ```
698-
/// let v = [10, 40, 30, 20, 60, 50];
699702
///
700-
/// for group in v.split(|num| *num % 3 == 0) {
701-
/// println!("{:?}", group);
702-
/// }
703+
/// If the first element is matched, an empty slice will be the first item
704+
/// returned by the iterator. Similarly, if the last element in the slice
705+
/// is matched, an empty slice will be the last item returned by the
706+
/// iterator:
707+
///
708+
/// ```
709+
/// let slice = [10, 40, 33];
710+
/// let mut iter = slice.split(|num| num % 3 == 0);
711+
///
712+
/// assert_eq!(iter.next().unwrap(), &[10, 40]);
713+
/// assert_eq!(iter.next().unwrap(), &[]);
714+
/// assert!(iter.next().is_none());
715+
/// ```
716+
///
717+
/// If two matched elements are directly adjacent, an empty slice will be
718+
/// present between them:
719+
///
720+
/// ```
721+
/// let slice = [10, 6, 33, 20];
722+
/// let mut iter = slice.split(|num| num % 3 == 0);
723+
///
724+
/// assert_eq!(iter.next().unwrap(), &[10]);
725+
/// assert_eq!(iter.next().unwrap(), &[]);
726+
/// assert_eq!(iter.next().unwrap(), &[20]);
727+
/// assert!(iter.next().is_none());
703728
/// ```
704729
#[stable(feature = "rust1", since = "1.0.0")]
705730
#[inline]

src/libcollections/vec_deque.rs

+16
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ impl<T> VecDeque<T> {
402402

403403
/// Retrieves an element in the `VecDeque` by index.
404404
///
405+
/// Element at index 0 is the front of the queue.
406+
///
405407
/// # Examples
406408
///
407409
/// ```
@@ -425,6 +427,8 @@ impl<T> VecDeque<T> {
425427

426428
/// Retrieves an element in the `VecDeque` mutably by index.
427429
///
430+
/// Element at index 0 is the front of the queue.
431+
///
428432
/// # Examples
429433
///
430434
/// ```
@@ -456,6 +460,8 @@ impl<T> VecDeque<T> {
456460
///
457461
/// Fails if there is no element with either index.
458462
///
463+
/// Element at index 0 is the front of the queue.
464+
///
459465
/// # Examples
460466
///
461467
/// ```
@@ -1180,6 +1186,8 @@ impl<T> VecDeque<T> {
11801186
///
11811187
/// Returns `None` if `index` is out of bounds.
11821188
///
1189+
/// Element at index 0 is the front of the queue.
1190+
///
11831191
/// # Examples
11841192
///
11851193
/// ```
@@ -1214,6 +1222,8 @@ impl<T> VecDeque<T> {
12141222
///
12151223
/// Returns `None` if `index` is out of bounds.
12161224
///
1225+
/// Element at index 0 is the front of the queue.
1226+
///
12171227
/// # Examples
12181228
///
12191229
/// ```
@@ -1245,6 +1255,8 @@ impl<T> VecDeque<T> {
12451255
/// end is closer to the insertion point will be moved to make room,
12461256
/// and all the affected elements will be moved to new positions.
12471257
///
1258+
/// Element at index 0 is the front of the queue.
1259+
///
12481260
/// # Panics
12491261
///
12501262
/// Panics if `index` is greater than `VecDeque`'s length
@@ -1472,6 +1484,8 @@ impl<T> VecDeque<T> {
14721484
/// room, and all the affected elements will be moved to new positions.
14731485
/// Returns `None` if `index` is out of bounds.
14741486
///
1487+
/// Element at index 0 is the front of the queue.
1488+
///
14751489
/// # Examples
14761490
///
14771491
/// ```
@@ -1651,6 +1665,8 @@ impl<T> VecDeque<T> {
16511665
///
16521666
/// Note that the capacity of `self` does not change.
16531667
///
1668+
/// Element at index 0 is the front of the queue.
1669+
///
16541670
/// # Panics
16551671
///
16561672
/// Panics if `at > len`

0 commit comments

Comments
 (0)