Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Taillefer committed Dec 6, 2024
1 parent 4c89bbb commit aefa18d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 37 deletions.
8 changes: 7 additions & 1 deletion frozen-collections-core/src/facade_maps/facade_string_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ where
#[must_use]
#[allow(clippy::missing_panics_doc)]
pub fn new_from_str(entries: Vec<(&str, V)>, bh: BH) -> Self {
Self::new(entries.into_iter().map(|(k, v)| (k.to_string(), v)).collect(), bh)
Self::new(
entries
.into_iter()
.map(|(k, v)| (k.to_string(), v))
.collect(),
bh,
)
}

#[doc = include_str!("../doc_snippets/get_method.md")]
Expand Down
5 changes: 2 additions & 3 deletions frozen-collections-core/src/macros/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ impl Generator {
if processed_entries.len() < SCAN_THRESHOLD {
Ok(self.emit_inline_scan(&processed_entries))
} else {
// Ok(self.emit_facade_for_entries(&processed_entries, "Scalar"))
Ok(self.emit_hash_with_bridge(&processed_entries))
Ok(self.emit_facade_for_entries(&processed_entries, "Scalar"))
}
}

Expand All @@ -434,7 +433,7 @@ impl Generator {
if processed_entries.len() < SCAN_THRESHOLD {
Ok(self.emit_inline_scan(&processed_entries))
} else {
// Ok(self.emit_facade_for_entries(&processed_entries, "String"))
// Ok(self.emit_facade_for_entries(&processed_entries, "String"))
Ok(self.emit_hash_with_bridge(&processed_entries))
}
}
Expand Down
8 changes: 4 additions & 4 deletions frozen-collections-core/src/macros/set_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mod tests {
fn test_selected_string_set_implementation_types() {
fn check_impl(expected: &str, ts: TokenStream) {
let r = fz_string_set_macro(ts).unwrap().to_string();
assert!(r.contains(expected), "{} doesn't contain {}", r, expected);
assert!(r.contains(expected), "{r} doesn't contain {expected}");
}

check_impl(":: InlineScanSet", quote!({ "1", "2", "3", }));
Expand All @@ -240,7 +240,7 @@ mod tests {
fn test_selected_scalar_set_implementation_types() {
fn check_impl(expected: &str, ts: TokenStream) {
let r = fz_scalar_set_macro(ts).unwrap().to_string();
assert!(r.contains(expected), "{} doesn't contain {}", r, expected);
assert!(r.contains(expected), "{r} doesn't contain {expected}");
}

check_impl(":: InlineDenseScalarLookupSet", quote!({ 1, 2, 3, }));
Expand All @@ -259,7 +259,7 @@ mod tests {
fn test_selected_ordered_set_implementation_types() {
fn check_impl(expected: &str, ts: TokenStream) {
let r = fz_ordered_set_macro(ts).unwrap().to_string();
assert!(r.contains(expected), "{} doesn't contain {}", r, expected);
assert!(r.contains(expected), "{r} doesn't contain {expected}");
}

check_impl(":: InlineDenseScalarLookupSet", quote!({ 1, 2, 3, }));
Expand Down Expand Up @@ -311,7 +311,7 @@ mod tests {
fn test_selected_hash_set_implementation_types() {
fn check_impl(expected: &str, ts: TokenStream) {
let r = fz_hash_set_macro(ts).unwrap().to_string();
assert!(r.contains(expected), "{} doesn't contain {}", r, expected);
assert!(r.contains(expected), "{r} doesn't contain {expected}");
}

check_impl(":: InlineDenseScalarLookupSet", quote!({ 1, 2, 3, }));
Expand Down
28 changes: 14 additions & 14 deletions frozen-collections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
//! use frozen_collections::*;
//!
//! let v = vec![
//! ("Alice".to_string(), 1),
//! ("Bob".to_string(), 2),
//! ("Sandy".to_string(), 3),
//! ("Tom".to_string(), 4),
//! ("Alice", 1),
//! ("Bob", 2),
//! ("Sandy", 3),
//! ("Tom", 4),
//! ];
//!
//! let m = fz_string_map!(v);
Expand Down Expand Up @@ -141,10 +141,10 @@
//! use frozen_collections::*;
//!
//! let v = vec![
//! ("Alice".to_string(), 1),
//! ("Bob".to_string(), 2),
//! ("Sandy".to_string(), 3),
//! ("Tom".to_string(), 4),
//! ("Alice", 1),
//! ("Bob", 2),
//! ("Sandy", 3),
//! ("Tom", 4),
//! ];
//!
//! fz_string_map!(let m: MyMapType<&str, i32> = v);
Expand Down Expand Up @@ -1061,16 +1061,16 @@ pub use frozen_collections_macros::fz_scalar_set;
/// });
///
/// let v = vec![
/// ("Alice".to_string(), 1),
/// ("Bob".to_string(), 2),
/// ("Alice", 1),
/// ("Bob", 2),
/// ];
///
/// // Declare a local map. This results in a local variable called my_map_5 of type MyMapType4.
/// fz_string_map!(let my_map_5: MyMapType4<&str, i32> = v);
///
/// let v = vec![
/// ("Alice".to_string(), 1),
/// ("Bob".to_string(), 2),
/// ("Alice", 1),
/// ("Bob", 2),
/// ];
///
/// // Declare a local map. This results in a local variable called my_map_6 of an unknown type.
Expand Down Expand Up @@ -1209,8 +1209,8 @@ pub use frozen_collections_macros::fz_string_map;
/// fz_string_set!(let my_set_5: MySetType4<&str> = v);
///
/// let v = vec![
/// "Alice".to_string(),
/// "Bob".to_string(),
/// "Alice",
/// "Bob",
/// ];
///
/// // Declare a local set. This results in a local variable called my_set_6 of an unknown type.
Expand Down
8 changes: 4 additions & 4 deletions frozen-collections/tests/common/map_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ where
assert_eq!(map.len(), reference.len());
assert_eq!(map.is_empty(), reference.is_empty());

for pairs in reference {
assert!(map.contains_key(pairs.0));
for pair in reference {
assert!(map.contains_key(pair.0));
}

for pairs in map.iter() {
assert!(reference.contains_key(pairs.0));
for pair in map.iter() {
assert!(reference.contains_key(pair.0));
}
}
25 changes: 14 additions & 11 deletions frozen-collections/tests/omni_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ macro_rules! test_all {
}

#[test]
#[allow(clippy::unreadable_literal)]
fn test_common() {
test_all!(1, 2, 3 ; 3, 4, 5);
test_all!(0, 1 ; 0, 1);
Expand All @@ -284,17 +285,19 @@ fn test_common() {
test_all!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 20);

test_all!(11_111, 11_112, 11_114, 11_115, 111_165, 111_175 ; 2_500, 333_333_333);

let i = 1;
test_all!(i, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1, i, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2u8, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1u8, i, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1, i, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2u8, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1u8, i, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(11111, 11112, 11114, 11115, 111165, 111175 ; 2500, 333333333);

/*
let i = 1;
test_all!(i, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1, i, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2u8, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1u8, i, 3, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1, i, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(i, 2u8, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
test_all!(1u8, i, 3u8, 4, 5, 6, 7, 8, 9, 10 ; 3);
*/
}

#[test]
Expand Down

0 comments on commit aefa18d

Please sign in to comment.