Mercurial > lbo > hg > memoize
changeset 98:e3495f149cdd
Add `compile_error`
author | blyxyas <blyxyas@gmail.com> |
---|---|
date | Tue, 17 Jan 2023 23:57:17 +0100 |
parents | 528ce50ec228 |
children | 0444f8e3099d |
files | inner/src/lib.rs |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/inner/src/lib.rs Sun Jan 15 13:15:04 2023 +0100 +++ b/inner/src/lib.rs Tue Jan 17 23:57:17 2023 +0100 @@ -1,6 +1,5 @@ #![crate_type = "proc-macro"] #![allow(unused_imports)] // Spurious complaints about a required trait import. - use syn::{self, parse, parse_macro_input, spanned::Spanned, Expr, ExprCall, ItemFn, Path}; use proc_macro::TokenStream; @@ -179,7 +178,10 @@ } Some(cap) => { if let Some(_) = &options.custom_hasher { - panic!("You can't use LRUMaxEntries and a Custom Hasher. Remove `LRUMaxEntries` from the attribute"); + ( + quote::quote! { compile_error!("Cannot use LRU cache and a custom hasher at the same time") }, + quote::quote! { std::collections::HashMap::new() }, + ) } else { ( quote::quote! { ::memoize::lru::LruCache<#key_type, #value_type> },