fera_graph/props/fn.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use props::PropGet;
6
7/// A read only property backed by a function.
8#[derive(Clone, Copy)]
9pub struct FnProp<F>(pub F);
10
11impl<F, I, T> PropGet<I> for FnProp<F>
12where
13 F: Fn(I) -> T,
14 T: Sized,
15{
16 type Output = T;
17
18 #[inline(always)]
19 fn get(&self, item: I) -> T {
20 (self.0)(item)
21 }
22}