1
1
mirror of https://github.com/casey/just.git synced 2024-11-23 20:15:05 +03:00

Implement Default for Table (#748)

This commit is contained in:
Casey Rodarmor 2021-01-22 23:34:01 -08:00 committed by GitHub
parent 1ecdbd5353
commit a14bc8c951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View File

@ -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(

View File

@ -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 {