Skip to content

Commit 05405f5

Browse files
committed
DOC: In From impls, move the documentation down to the method
Once upon a time, rustdoc only supported the doc on top of the impl. Now it can be on the method. And it looks like if we have doc for `from`, then the link from the conversions table works (because the from method is now expanded by default).
1 parent 254a4f9 commit 05405f5

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/arraytraits.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,12 @@ pub const ARRAY_FORMAT_VERSION: u8 = 1u8;
215215

216216
// use "raw" form instead of type aliases here so that they show up in docs
217217
/// Implementation of `ArrayView::from(&S)` where `S` is a slice or slicable.
218-
///
219-
/// Create a one-dimensional read-only array view of the data in `slice`.
220-
///
221-
/// **Panics** if the slice length is greater than `isize::MAX`.
222218
impl<'a, A, Slice: ?Sized> From<&'a Slice> for ArrayView<'a, A, Ix1>
223219
where Slice: AsRef<[A]>
224220
{
221+
/// Create a one-dimensional read-only array view of the data in `slice`.
222+
///
223+
/// **Panics** if the slice length is greater than `isize::MAX`.
225224
fn from(slice: &'a Slice) -> Self {
226225
let xs = slice.as_ref();
227226
if mem::size_of::<A>() == 0 {
@@ -237,25 +236,23 @@ impl<'a, A, Slice: ?Sized> From<&'a Slice> for ArrayView<'a, A, Ix1>
237236
}
238237

239238
/// Implementation of `ArrayView::from(&A)` where `A` is an array.
240-
///
241-
/// Create a read-only array view of the array.
242239
impl<'a, A, S, D> From<&'a ArrayBase<S, D>> for ArrayView<'a, A, D>
243240
where S: Data<Elem=A>,
244241
D: Dimension,
245242
{
243+
/// Create a read-only array view of the array.
246244
fn from(array: &'a ArrayBase<S, D>) -> Self {
247245
array.view()
248246
}
249247
}
250248

251249
/// Implementation of `ArrayViewMut::from(&mut S)` where `S` is a slice or slicable.
252-
///
253-
/// Create a one-dimensional read-write array view of the data in `slice`.
254-
///
255-
/// **Panics** if the slice length is greater than `isize::MAX`.
256250
impl<'a, A, Slice: ?Sized> From<&'a mut Slice> for ArrayViewMut<'a, A, Ix1>
257251
where Slice: AsMut<[A]>
258252
{
253+
/// Create a one-dimensional read-write array view of the data in `slice`.
254+
///
255+
/// **Panics** if the slice length is greater than `isize::MAX`.
259256
fn from(slice: &'a mut Slice) -> Self {
260257
let xs = slice.as_mut();
261258
if mem::size_of::<A>() == 0 {
@@ -271,12 +268,11 @@ impl<'a, A, Slice: ?Sized> From<&'a mut Slice> for ArrayViewMut<'a, A, Ix1>
271268
}
272269

273270
/// Implementation of `ArrayViewMut::from(&mut A)` where `A` is an array.
274-
///
275-
/// Create a read-write array view of the array.
276271
impl<'a, A, S, D> From<&'a mut ArrayBase<S, D>> for ArrayViewMut<'a, A, D>
277272
where S: DataMut<Elem=A>,
278273
D: Dimension,
279274
{
275+
/// Create a read-write array view of the array.
280276
fn from(array: &'a mut ArrayBase<S, D>) -> Self {
281277
array.view_mut()
282278
}

0 commit comments

Comments
 (0)