Skip to content

Commit 5fd38bb

Browse files
committed
---
yaml --- r: 218349 b: refs/heads/master c: 1abdd13 h: refs/heads/master i: 218347: 0a7de14 v: v3
1 parent d363531 commit 5fd38bb

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6c4e236b955ba6a2dd8ef8e054f50ff64135a8be
2+
refs/heads/master: 1abdd130d8308d083741bb131256b95f5543e23c
33
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/libstd/array.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,48 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! The fixed-size array type (`[T; n]`).
11+
//! A fixed-size array is denoted `[T; N]` for the element type `T` and
12+
//! the compile time constant size `N`. The size should be zero or positive.
1213
//!
13-
//! Some usage examples:
14+
//! Arrays values are created either with an explicit expression that lists
15+
//! each element: `[x, y, z]` or a repeat expression: `[x; N]`. The repeat
16+
//! expression requires that the element type is `Copy`.
17+
//!
18+
//! The type `[T; N]` is `Copy` if `T: Copy`.
19+
//!
20+
//! Arrays of sizes from 0 to 32 (inclusive) implement the following traits
21+
//! if the element type allows it:
22+
//!
23+
//! - `Clone`
24+
//! - `Debug`
25+
//! - `IntoIterator` (implemented for `&[T; N]` and `&mut [T; N]`)
26+
//! - `PartialEq`, `PartialOrd`, `Ord`, `Eq`
27+
//! - `Hash`
28+
//! - `AsRef`, `AsMut`
29+
//!
30+
//! Arrays dereference to [slices (`[T]`)][slice], so their methods can be called
31+
//! on arrays.
32+
//!
33+
//! [slice]: primitive.slice.html
34+
//!
35+
//! ## Examples
1436
//!
1537
//! ```
16-
//! let array: [i32; 3] = [0, 1, 2];
38+
//! let mut array: [i32; 3] = [0; 3];
39+
//!
40+
//! array[1] = 1;
41+
//! array[2] = 2;
1742
//!
18-
//! assert_eq!(0, array[0]);
19-
//! assert_eq!([0, 1], &array[..2]);
43+
//! assert_eq!([1, 2], &array[1..]);
2044
//!
45+
//! // This loop prints: 0 1 2
2146
//! for x in &array {
22-
//! println!("{}", x);
47+
//! print!("{} ", x);
2348
//! }
49+
//!
2450
//! ```
51+
//!
52+
//! Rust does not currently support generics over the size of an array type.
53+
//!
2554
2655
#![doc(primitive = "array")]

0 commit comments

Comments
 (0)