Crates.io | rev_slice |
lib.rs | rev_slice |
version | 0.1.5 |
source | src |
created_at | 2018-08-05 00:24:53.899546 |
updated_at | 2018-10-23 06:35:09.7965 |
description | A newtype for operating on a reversed view of a slice. |
homepage | |
repository | https://github.com/scottmcm/rev_slice |
max_upload_size | |
id | 77542 |
size | 9,571 |
A simple alternative to negative indexing on rust slices
Ever wanted a[-1]
in Rust? With this crate, you can do that as a.rev()[0]
.
Also provided are the other slice methods on the reversed slice, and you can
.rev()
again to get the original slice back. So you can, for example,
remove the last element of a slice with a.rev()[1..].rev()
.