#slice

subslice_index

Get the index of a subslice into its parent slice

1 unstable release

Uses old Rust 2015

0.5.0 Feb 11, 2017

#272 in #slice

32 downloads per month
Used in 2 crates

MIT license

3KB

subslice_index

Documentation

Get the index of a subslice into its parent slice.

Example

use subslice_index::subslice_index;

let arr = [1, 2, 3, 4, 5, 6];

let slice = &arr[..];
let subslice = &slice[2..4];

assert_eq!(subslice, [3, 4]);
assert_eq!(subslice_index(slice, subslice), 2);

Usage

This crate can be used through cargo by adding it as a dependency in Cargo.toml:

[dependencies]
subslice_index = "0.5.0"

and importing it in the crate root:

extern crate subslice_index;

lib.rs:

Get the index of a subslice into its parent slice.

Example

use subslice_index::subslice_index;

let arr = [1, 2, 3, 4, 5, 6];

let slice = &arr[..];
let subslice = &slice[2..4];

assert_eq!(subslice, [3, 4]);
assert_eq!(subslice_index(slice, subslice), 2);

No runtime deps