From a14bc8c9513930ec199b4f04bba74378479f5424 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 22 Jan 2021 23:34:01 -0800 Subject: [PATCH] Implement `Default` for `Table` (#748) --- src/analyzer.rs | 14 ++------------ src/table.rs | 6 ++++++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/analyzer.rs b/src/analyzer.rs index 76b9ce87..4b502eaa 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -2,6 +2,7 @@ use crate::common::*; use CompilationErrorKind::*; +#[derive(Default)] pub(crate) struct Analyzer<'src> { recipes: Table<'src, UnresolvedRecipe<'src>>, assignments: Table<'src, Assignment<'src>>, @@ -11,18 +12,7 @@ pub(crate) struct Analyzer<'src> { impl<'src> Analyzer<'src> { pub(crate) fn analyze(module: Module<'src>) -> CompilationResult<'src, Justfile> { - let analyzer = Analyzer::new(); - - analyzer.justfile(module) - } - - pub(crate) fn new() -> Analyzer<'src> { - Analyzer { - recipes: empty(), - assignments: empty(), - aliases: empty(), - sets: empty(), - } + Analyzer::default().justfile(module) } pub(crate) fn justfile( diff --git a/src/table.rs b/src/table.rs index ae48e4de..a336f662 100644 --- a/src/table.rs +++ b/src/table.rs @@ -55,6 +55,12 @@ impl<'key, V: Keyed<'key>> Table<'key, V> { } } +impl<'key, V: Keyed<'key>> Default for Table<'key, V> { + fn default() -> Self { + Self::new() + } +} + impl<'key, V: Keyed<'key>> FromIterator for Table<'key, V> { fn from_iter>(iter: I) -> Self { Table {