defaultmap icon indicating copy to clipboard operation
defaultmap copied to clipboard

Add a feature gat to ignore the default field in serde and make it transparent

Open janTatesa opened this issue 8 months ago • 0 comments

The code would be


/// A `HashMap` that returns a default when keys are accessed that are not present.

#[derive(Clone, Debug)]

#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde-ignore-default", serde(transparent)))]
pub struct DefaultHashMap<K: Eq + Hash, V> {
    map: HashMap<K, V>,
    #[cfg_attr(feature = "serde-ignore-default", serde(skip)))]
    default: V,

    #[debug(skip)]
    #[cfg_attr(feature = "with-serde", serde(skip))]
    default_fn: Box<dyn DefaultFn<V>>,

}

janTatesa avatar Apr 29 '25 11:04 janTatesa