Skip to content

Commit 9a5aaf2

Browse files
committed
Make Module generic over type of file paths.
1 parent 98e8ae5 commit 9a5aaf2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

jaq-syn/src/parse.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,21 @@ impl<'s, 't> Parser<'s, 't> {
677677
/// def iter: .[];
678678
/// ~~~
679679
#[derive(Debug, Default)]
680-
pub struct Module<S, B> {
680+
pub struct Module<S, B, P = S> {
681681
#[allow(dead_code)]
682682
meta: Option<Term<S>>,
683-
pub(crate) mods: Vec<(S, Option<S>)>,
683+
pub(crate) mods: Vec<(P, Option<S>)>,
684684
pub(crate) body: B,
685685
}
686686

687+
impl<S, B, P> Module<S, B, P> {
688+
pub(crate) fn map_paths<P2>(self, mut f: impl FnMut(P) -> P2) -> Module<S, B, P2> {
689+
let Module { meta, mods, body } = self;
690+
let mods = mods.into_iter().map(|(path, as_)| (f(path), as_)).collect();
691+
Module { meta, mods, body }
692+
}
693+
}
694+
687695
/// jq definition, consisting of a name, optional arguments, and a body.
688696
///
689697
/// Examples:

0 commit comments

Comments
 (0)