mirror of
https://github.com/rust-lang/rust
synced 2024-10-19 15:03:55 +00:00
Use 0-based idx for array content
This commit is contained in:
parent
a8e9708aeb
commit
73a5f01263
|
@ -1216,10 +1216,10 @@ pub const fn and<U>(self, optb: Option<U>) -> Option<U>
|
|||
/// Often used to chain fallible operations that may return [`None`].
|
||||
///
|
||||
/// ```
|
||||
/// let arr_2d = [["A1", "A2"], ["B1", "B2"]];
|
||||
/// let arr_2d = [["A0", "A1"], ["B0", "B1"]];
|
||||
///
|
||||
/// let item_0_1 = arr_2d.get(0).and_then(|row| row.get(1));
|
||||
/// assert_eq!(item_0_1, Some(&"A2"));
|
||||
/// assert_eq!(item_0_1, Some(&"A1"));
|
||||
///
|
||||
/// let item_2_0 = arr_2d.get(2).and_then(|row| row.get(0));
|
||||
/// assert_eq!(item_2_0, None);
|
||||
|
|
Loading…
Reference in a new issue