Skip to content

Commit

Permalink
Restored macros in causable extension
Browse files Browse the repository at this point in the history
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
  • Loading branch information
marvin-hansen committed Sep 13, 2023
1 parent 9a36c7d commit 63e1280
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions deep_causality/src/extensions/causable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::hash::Hash;

// Extension trait http://xion.io/post/code/rust-extension-traits.html
use deep_causality_macros::{
make_array_to_vec, make_get_all_items, make_get_all_map_items, make_len, make_map_to_vec,
make_vec_to_vec,
make_array_to_vec, make_get_all_items, make_get_all_map_items, make_is_empty, make_len,
make_map_to_vec, make_vec_to_vec,
};

use crate::prelude::{Causable, CausableReasoning};
Expand All @@ -17,11 +17,9 @@ where
T: Causable + Clone,
{
make_len!();
make_is_empty!();
make_get_all_items!();
make_array_to_vec!();
fn is_empty(&self) -> bool {
self.is_empty()
}
}

impl<K, V> CausableReasoning<V> for BTreeMap<K, V>
Expand All @@ -30,11 +28,9 @@ where
V: Causable + Clone,
{
make_len!();
make_is_empty!();
make_map_to_vec!();
make_get_all_map_items!();
fn is_empty(&self) -> bool {
self.is_empty()
}
}

impl<K, V> CausableReasoning<V> for HashMap<K, V>
Expand All @@ -43,35 +39,28 @@ where
V: Causable + Clone,
{
make_len!();
make_is_empty!();
make_map_to_vec!();
make_get_all_map_items!();
fn is_empty(&self) -> bool {
self.is_empty()
}
}

impl<T> CausableReasoning<T> for Vec<T>
where
T: Causable + Clone,
{
make_len!();
make_is_empty!();
make_vec_to_vec!();
make_get_all_items!();
fn is_empty(&self) -> bool {
self.is_empty()
}
}

impl<T> CausableReasoning<T> for VecDeque<T>
where
T: Causable + Clone,
{
make_len!();
make_is_empty!();
make_get_all_items!();
fn is_empty(&self) -> bool {
self.is_empty()
}

// VecDeque can't be turned into a vector hence the custom implementation
// https://github.com/rust-lang/rust/issues/23308
// Also, make_contiguous requires self to be mutable, which would violate the API, hence the clone.
Expand Down

0 comments on commit 63e1280

Please sign in to comment.