Skip to content

Commit

Permalink
#5 MaybeUninit
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Apr 17, 2023
1 parent 88570fc commit 920eb97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use crate::Pair::{Absent, Present};
use crate::{IntoIter, Iter, Map, Pair};
use std::mem::MaybeUninit;

impl<K: Copy + PartialEq, V: Clone + Copy, const N: usize> Default for Map<K, V, N> {
fn default() -> Self {
Expand All @@ -34,7 +35,7 @@ impl<K: Copy + PartialEq, V: Clone + Copy, const N: usize> Map<K, V, N> {
pub fn new() -> Self {
Self {
next: 0,
pairs: [Pair::<K, V>::default(); N],
pairs: unsafe { *MaybeUninit::<[Pair<K, V>; N]>::uninit().as_mut_ptr() },
}
}

Expand Down

0 comments on commit 920eb97

Please sign in to comment.