suss/
mapfut.rs

1//! Simple module for mapping the result of a future in-place.
2
3use std::future::Future;
4
5/// Takes a future and a map, and maps the result of that future with a function.
6pub async fn map_fut<T, Q>(f: impl Future<Output = T>, t: impl FnOnce(T) -> Q) -> Q {
7    t(f.await)
8}
9
10// suss - library for creating single, directory namespaced unix socket servers in a network
11// Copyright (C) 2022  Matti Bryce <mattibryce@protonmail.com>
12
13// This program is free software: you can redistribute it and/or modify
14// it under the terms of the GNU Affero General Public License as published
15// by the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17
18// This program is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21// GNU Affero General Public License for more details.
22
23// You should have received a copy of the GNU Affero General Public License
24// along with this program.  If not, see <https://www.gnu.org/licenses/>.