Define IndexTo<Data, Owner, Idx=usize>, a strongly typed index for vector, slice, and str type.
Also define a 10usize.get(&myVec) and IndexLike.getMut(Inside) to access value from an index.
Provides optional support for Serde (serialization / deserialization) when the "serde" feature is enabled.
use *;
use Index;
type IntegerIdx = IndexTo;
type BooleanIdx = IndexTo;
// can also be written as
// type IntegerIdx = IndexTo<i32 , Vec<i32 >>;
// type BooleanIdx = IndexTo<bool, Vec<bool>>;
let mut int_and_bool = IntAndBool ;
let int_idx = int_and_bool.integers.index_to; // 20
let bool_idx = int_and_bool.booleans.index_to; // true
// the magic in strongly typed index is here :
assert_eq!;
assert_eq!;
// compile time error :
// let b = int_and_bool.booleans[int_idx ];
// let i = int_and_bool.integers[bool_idx];
let int_idx_2 = from_index; // 20
let bool_idx_2 = from_index; // true
assert_eq!;
assert_eq!;
// Also define the `typed_index()` method similar to `index()`
assert_eq!;
assert_eq!;
// Also define the `typed_index_mut()` method similar to `index_mut()`
assert_eq!;
assert_eq!;