id_sys 0.1.0

Provides data structures which can be marked such that they only work with similarly marked integer data types.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{internal::Sealed, IdSlice};

pub trait SliceExt<TValue>: Sealed {
    fn as_id_slice<TMarker: ?Sized>(&self) -> &IdSlice<TMarker, TValue>;

    fn as_mut_id_slice<TMarker: ?Sized>(&mut self) -> &mut IdSlice<TMarker, TValue>;
}

impl<TValue> SliceExt<TValue> for [TValue] {
    fn as_id_slice<TMarker: ?Sized>(&self) -> &IdSlice<TMarker, TValue> {
        IdSlice::from_slice(self)
    }

    fn as_mut_id_slice<TMarker: ?Sized>(&mut self) -> &mut IdSlice<TMarker, TValue> {
        IdSlice::from_mut_slice(self)
    }
}