Skip to content

Commit 11921b8

Browse files
committed
Make Index docs actually render
1 parent 801d641 commit 11921b8

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/array.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -192,34 +192,33 @@ tuple_impl!(a: isize, b: isize, c: isize, d: isize, e: isize, f: isize, g: isize
192192
tuple_impl!(a: isize, b: isize, c: isize, d: isize, e: isize, f: isize, g: isize, h: isize);
193193
tuple_impl!(a: isize, b: isize, c: isize, d: isize, e: isize, f: isize, g: isize, h: isize, i: isize);
194194

195+
/// Indexes into the `Array`, retrieving a reference to the contained
196+
/// value.
197+
///
198+
/// Since `Array`s can be multi-dimensional, the `Index` trait is
199+
/// implemented for a variety of index types. In the most generic case, a
200+
/// `&[isize]` can be used. In addition, a bare `isize` as well as tuples
201+
/// of up to 10 `isize` values may be used for convenience.
202+
///
203+
/// # Panics
204+
///
205+
/// Panics if the index does not correspond to an in-bounds element of the
206+
/// `Array`.
207+
///
208+
/// # Examples
209+
///
210+
/// ```rust
211+
/// # use postgres_array::Array;
212+
/// let mut array = Array::from_vec(vec![0i32, 1, 2, 3], 0);
213+
/// assert_eq!(2, array[2]);
214+
///
215+
/// array.wrap(0);
216+
/// array.push(Array::from_vec(vec![4, 5, 6, 7], 0));
217+
///
218+
/// assert_eq!(6, array[(1, 2)]);
219+
/// ```
195220
impl<T, I: ArrayIndex> Index<I> for Array<T> {
196221
type Output = T;
197-
198-
/// Indexes into the `Array`, retrieving a reference to the contained
199-
/// value.
200-
///
201-
/// Since `Array`s can be multi-dimensional, the `Index` trait is
202-
/// implemented for a variety of index types. In the most generic case, a
203-
/// `&[isize]` can be used. In addition, a bare `isize` as well as tuples
204-
/// of up to 10 `isize` values may be used for convenience.
205-
///
206-
/// # Panics
207-
///
208-
/// Panics if the index does not correspond to an in-bounds element of the
209-
/// `Array`.
210-
///
211-
/// # Examples
212-
///
213-
/// ```rust
214-
/// # use postgres_array::Array;
215-
/// let mut array = Array::from_vec(vec![0i32, 1, 2, 3], 0);
216-
/// assert_eq!(2, array[2]);
217-
///
218-
/// array.wrap(0);
219-
/// array.push(Array::from_vec(vec![4, 5, 6, 7], 0));
220-
///
221-
/// assert_eq!(6, array[(1, 2)]);
222-
/// ```
223222
fn index(&self, idx: I) -> &T {
224223
let idx = idx.index(self);
225224
&self.data[idx]

0 commit comments

Comments
 (0)