unchecked-indexing

Unchecked indexing through the regular index syntax.

Using a wrapper type that requires an unsafe block to create.

Example

```rust

use uncheckedindex::uncheckedindex;

/// unsafe because: trusts the permutation to be correct unsafe fn applypermutation(perm: &mut [usize], v: &mut [T]) { debugassert_eq!(perm.len(), v.len());

// use unchecked (in reality, debug-checked) indexing throughout
let mut perm = unchecked_index(perm);

for i in 0..perm.len() {
    let mut current = i;
    while i != perm[current] {
        let next = perm[current];
        // move element from next to current
        v.swap(next, current);
        perm[current] = current;
        current = next;
    }
    perm[current] = current;
}

} ```

How to contribute:

Recent Changes