prefer default over new

This commit is contained in:
BenjaminBrienen 2025-04-04 15:49:50 +02:00
parent 6ca780700d
commit 2462624a7d
46 changed files with 100 additions and 127 deletions

View file

@ -101,20 +101,15 @@ pub struct Map<A: ?Sized + Downcast = dyn Any> {
/// `Map::new()` doesnt seem to be happy to infer that it should go with the default
/// value. Its a bit sad, really. Ah well, I guess this approach will do.
pub type AnyMap = Map<dyn Any>;
impl<A: ?Sized + Downcast> Default for Map<A> {
#[inline]
fn default() -> Map<A> {
Map::new()
Map { raw: RawMap::with_hasher(Default::default()) }
}
}
impl<A: ?Sized + Downcast> Map<A> {
/// Create an empty collection.
#[inline]
pub fn new() -> Map<A> {
Map { raw: RawMap::with_hasher(Default::default()) }
}
/// Returns a reference to the value stored in the collection for the type `T`,
/// if it exists.
#[inline]