// // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // //! Map implementation. //! //! Will be automatically included when including `filter::Filter`, so importing this module //! shouldn't be necessary. //! use std::marker::PhantomData; use std::borrow::Borrow; use filter::Filter; #[must_use = "filters are lazy and do nothing unless consumed"] #[derive(Clone)] pub struct MapInput(F, M, PhantomData, PhantomData); impl MapInput { pub fn new(a: F, m: M) -> MapInput { MapInput(a, m, PhantomData, PhantomData) } } impl Filter for MapInput where F: Filter, B: Borrow + Sized, M: Fn(&T) -> B { fn filter(&self, e: &T) -> bool { self.0.filter(self.1(e).borrow()) } }