Skip to content

Commit

Permalink
test for ::default()
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Apr 25, 2023
1 parent a30bfda commit a68142d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/ctors.rs
Expand Up @@ -21,6 +21,12 @@
use crate::{Map, Pair};
use std::mem::MaybeUninit;

impl<K: Clone + PartialEq, V: Clone, const N: usize> Default for Map<K, V, N> {
fn default() -> Self {
Self::new()
}
}

impl<K: Clone + PartialEq, V: Clone, const N: usize> Map<K, V, N> {
/// Make it.
#[inline]
Expand All @@ -39,6 +45,13 @@ impl<K: Clone + PartialEq, V: Clone, const N: usize> Map<K, V, N> {
#[cfg(test)]
use anyhow::Result;

#[test]
fn makes_default_map() -> Result<()> {
let m: Map<u8, u8, 8> = Map::default();
assert_eq!(0, m.len());
Ok(())
}

#[test]
fn makes_new_map() -> Result<()> {
let m: Map<u8, u8, 8> = Map::new();
Expand Down
6 changes: 0 additions & 6 deletions src/map.rs
Expand Up @@ -23,12 +23,6 @@ use crate::{IntoIter, Iter, Map};
use std::borrow::Borrow;
use std::mem::MaybeUninit;

impl<K: Clone + PartialEq, V: Clone, const N: usize> Default for Map<K, V, N> {
fn default() -> Self {
Self::new()
}
}

impl<K: PartialEq + Clone, V: Clone, const N: usize> Map<K, V, N> {
/// Make an iterator over all pairs.
#[inline]
Expand Down

0 comments on commit a68142d

Please sign in to comment.