Skip to content

Commit

Permalink
Implement Default for Table (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 23, 2021
1 parent 1ecdbd5 commit a14bc8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<V> for Table<'key, V> {
fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self {
Table {
Expand Down

0 comments on commit a14bc8c

Please sign in to comment.