ndarray
ndarray copied to clipboard
Improve documentation of slicing methods.
Thanks for suggesting improvements to the docs.
It's somewhat awkward to reference a few other slicing methods without listing all of the potentially relevant ones. However, I don't think we should list all of them, since there are a lot of slicing methods, and they're all mentioned in the Slicing docs already.
What I'd suggest is to address the question in #988 more directly, i.e. add something like the following to the docs for .slice():
Note that the lifetime of the resulting slice corresponds to the
&selfborrow. If you want a slice with the same lifetime as an existing view, clone/copy the view if necessary and then use.slice_move()or.slice_collapse().
and add the following to the docs for .slice_mut():
Note that the lifetime of the resulting slice corresponds to the
&mut selfborrow. If you want a slice with the same lifetime as an existing view, use.slice_move(),.multi_slice_move(), or.slice_collapse()on the view.
We could also add analogous comments to the docs of slice_axis/_mut (referencing slice_axis_inplace) and slice_each_axis/_mut (referencing slice_each_axis_inplace).
One other note: the markup of the links in this PR isn't quite right. A link should be formatted like this:
some text [the link text](url) more text
or like this:
some text [the link text] more text
[the link text]: url
Note also that as of Rust 1.48.0, it's possible to use the Rust path of an in-scope item as a "URL", and as of Rust 1.51.0, this works for associated items too, such as writing [.slice()](ArrayBase::slice).