Implement Default
for Table
(#748)
This commit is contained in:
parent
1ecdbd5353
commit
a14bc8c951
@ -2,6 +2,7 @@ use crate::common::*;
|
|||||||
|
|
||||||
use CompilationErrorKind::*;
|
use CompilationErrorKind::*;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub(crate) struct Analyzer<'src> {
|
pub(crate) struct Analyzer<'src> {
|
||||||
recipes: Table<'src, UnresolvedRecipe<'src>>,
|
recipes: Table<'src, UnresolvedRecipe<'src>>,
|
||||||
assignments: Table<'src, Assignment<'src>>,
|
assignments: Table<'src, Assignment<'src>>,
|
||||||
@ -11,18 +12,7 @@ pub(crate) struct Analyzer<'src> {
|
|||||||
|
|
||||||
impl<'src> Analyzer<'src> {
|
impl<'src> Analyzer<'src> {
|
||||||
pub(crate) fn analyze(module: Module<'src>) -> CompilationResult<'src, Justfile> {
|
pub(crate) fn analyze(module: Module<'src>) -> CompilationResult<'src, Justfile> {
|
||||||
let analyzer = Analyzer::new();
|
Analyzer::default().justfile(module)
|
||||||
|
|
||||||
analyzer.justfile(module)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn new() -> Analyzer<'src> {
|
|
||||||
Analyzer {
|
|
||||||
recipes: empty(),
|
|
||||||
assignments: empty(),
|
|
||||||
aliases: empty(),
|
|
||||||
sets: empty(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn justfile(
|
pub(crate) fn justfile(
|
||||||
|
@ -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> {
|
impl<'key, V: Keyed<'key>> FromIterator<V> for Table<'key, V> {
|
||||||
fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self {
|
fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self {
|
||||||
Table {
|
Table {
|
||||||
|
Loading…
Reference in New Issue
Block a user