Skip to content

Commit

Permalink
Add const_evaluatable_checked feature (#23)
Browse files Browse the repository at this point in the history
* Add `const_evaluatable_checked` feature

Required for `{Truncated,Extended}Vector` types.

* Use `MaybeUninit::uninit_array()`
  • Loading branch information
hovind authored Oct 2, 2020
1 parent 809ea24 commit 0e5edbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,19 @@
//! ```
#![allow(incomplete_features)]
#![feature(const_evaluatable_checked)]
#![feature(const_generics)]
#![feature(trivial_bounds)]
#![feature(maybe_uninit_ref)]
#![feature(maybe_uninit_uninit_array)]

use core::{
cmp::PartialOrd,
fmt,
hash::{Hash, Hasher},
iter::{FromIterator, Product},
marker::PhantomData,
mem::{self, MaybeUninit},
mem::{self, transmute_copy, MaybeUninit},
ops::{
Add, AddAssign, Deref, DerefMut, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub,
SubAssign,
Expand Down
6 changes: 3 additions & 3 deletions src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,12 @@ impl<const N: usize> DerefMut for Permutation<{ N }> {
impl<const N: usize> Permutation<{ N }> {
/// Returns the unit permutation.
pub fn unit() -> Permutation<{ N }> {
let mut arr = MaybeUninit::<[usize; N]>::uninit();
let mut arr: [MaybeUninit<usize>; N] = MaybeUninit::uninit_array();
let arr = unsafe {
for i in 0..N {
*arr.get_mut().index_mut(i) = i;
arr[i] = MaybeUninit::new(i);
}
arr.assume_init()
transmute_copy::<_, _>(&arr)
};
Permutation { arr, num_swaps: 0 }
}
Expand Down

0 comments on commit 0e5edbd

Please sign in to comment.