From 4ff536cb593aa022e71042ab4fe008e2381b0680 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 20 Mar 2020 11:46:46 +0000 Subject: Remove more unnecessary parens in printer --- dhall/src/syntax/ast/import.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'dhall/src/syntax/ast/import.rs') diff --git a/dhall/src/syntax/ast/import.rs b/dhall/src/syntax/ast/import.rs index 75d7946..c45fe51 100644 --- a/dhall/src/syntax/ast/import.rs +++ b/dhall/src/syntax/ast/import.rs @@ -1,3 +1,5 @@ +use crate::syntax::trivial_result; + /// The beginning of a file path which anchors subsequent path components #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum FilePrefix { @@ -75,6 +77,12 @@ impl URL { headers, }) } + pub fn map_ref<'a, SE2>( + &'a self, + f: impl FnOnce(&'a SE) -> SE2, + ) -> URL { + trivial_result(self.traverse_ref(|x| Ok(f(x)))) + } } impl ImportTarget { @@ -90,6 +98,12 @@ impl ImportTarget { Missing => Missing, }) } + pub fn map_ref<'a, SE2>( + &'a self, + f: impl FnOnce(&'a SE) -> SE2, + ) -> ImportTarget { + trivial_result(self.traverse_ref(|x| Ok(f(x)))) + } } impl Import { @@ -103,4 +117,10 @@ impl Import { hash: self.hash.clone(), }) } + pub fn map_ref<'a, SE2>( + &'a self, + f: impl FnOnce(&'a SE) -> SE2, + ) -> Import { + trivial_result(self.traverse_ref(|x| Ok(f(x)))) + } } -- cgit v1.2.3