Skip to content

Implement TryFrom<[(K, V); N]> for ArrayMap<K, V, M> #13

Description

@Luro02

ArrayMapFacade could implement this:

impl<K,V,R,B,constN:usize>TryFrom<[(K,V);N]>forArrayMapFacade<K,V,R,B>whereK:Eq + Hash,R:RawTable<(K,V)> + Default,B:BuildHasher + Default,{typeError = CapacityError;fntry_from(value:[(K,V);N]) -> Result<Self,Self::Error>{letmut result = Self::with_build_hasher(B::default());for(key, value)in value {
result.insert(key, value)?;}Ok(result)}}

but it conflicts with the "specialized" implementation for FixedSizeTables:

array-map/src/array_map.rs

Lines 1064 to 1081 in 4390c72

impl<K,V,R,B,constN:usize>From<[(K,V);N]>forArrayMapFacade<K,V,R,B>
where
K:Eq + Hash,
R:FixedSizeTable<(K,V),N> + Default,
B:BuildHasher + Default,
{
fnfrom(value:[(K,V);N]) -> Self{
letmut result = Self::with_build_hasher(B::default());
for(key, value)in value {
ifletErr(error) = result.insert(key, value){
unreachable_unchecked!(error);
}
}
result
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions