Skip to content

Commit

Permalink
Make Module generic over type of file paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
01mf02 committed Jul 23, 2024
1 parent 98e8ae5 commit 9a5aaf2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jaq-syn/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,13 +677,21 @@ impl<'s, 't> Parser<'s, 't> {
/// def iter: .[];
/// ~~~
#[derive(Debug, Default)]
pub struct Module<S, B> {
pub struct Module<S, B, P = S> {
#[allow(dead_code)]
meta: Option<Term<S>>,
pub(crate) mods: Vec<(S, Option<S>)>,
pub(crate) mods: Vec<(P, Option<S>)>,
pub(crate) body: B,
}

impl<S, B, P> Module<S, B, P> {
pub(crate) fn map_paths<P2>(self, mut f: impl FnMut(P) -> P2) -> Module<S, B, P2> {
let Module { meta, mods, body } = self;
let mods = mods.into_iter().map(|(path, as_)| (f(path), as_)).collect();
Module { meta, mods, body }
}
}

/// jq definition, consisting of a name, optional arguments, and a body.
///
/// Examples:
Expand Down

0 comments on commit 9a5aaf2

Please sign in to comment.