From cebdd3be32d50be379663e92d4428e6bba19ba51 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sun, 2 Apr 2023 21:59:22 +0200 Subject: Run cargo fmt I think readability was better before that... --- tests/trivial_lifetime.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'tests/trivial_lifetime.rs') diff --git a/tests/trivial_lifetime.rs b/tests/trivial_lifetime.rs index 4f7d094..04d2d4a 100644 --- a/tests/trivial_lifetime.rs +++ b/tests/trivial_lifetime.rs @@ -1,39 +1,44 @@ #![deny(clippy::pedantic)] #![deny(clippy::all)] //! Tests if a trivial functor, which's lifetime depends on the mapping function, works. -use std::rc::Rc; -use higher::{Functor, Bind}; +use higher::{Bind, Functor}; use higher_free_macro::free; +use std::rc::Rc; #[derive(Clone)] -struct TrivWithLifetime<'a,A,B>{ - next : RcA + 'a>, +struct TrivWithLifetime<'a, A, B> { + next: Rc A + 'a>, } -impl<'a,A : 'a,B : 'a> Functor<'a,A> for TrivWithLifetime<'a,A,B> { - type Target = TrivWithLifetime<'a,T,B>; +impl<'a, A: 'a, B: 'a> Functor<'a, A> for TrivWithLifetime<'a, A, B> { + type Target = TrivWithLifetime<'a, T, B>; fn fmap(self, f: F) -> Self::Target where - F: Fn(A) -> C + 'a { - TrivWithLifetime{ next : Rc::new(move |x| f((self.next)(x)))} + F: Fn(A) -> C + 'a, + { + TrivWithLifetime { + next: Rc::new(move |x| f((self.next)(x))), + } } } free!(<'a>, FreeTriv<'a,A,B>, TrivWithLifetime<'a,FreeTriv<'a,A,B>,B>); #[test] -fn test_trivial_with_lifetime(){ - let f = FreeTriv::lift_f(TrivWithLifetime{next : Rc::new(i32::unsigned_abs)}); +fn test_trivial_with_lifetime() { + let f = FreeTriv::lift_f(TrivWithLifetime { + next: Rc::new(i32::unsigned_abs), + }); let f = f.bind(FreeTriv::Pure); match f { FreeTriv::Free(f) => { let n = (f.next)(-4); match n { - FreeTriv::Pure(v) => assert_eq!(v,4u32), + FreeTriv::Pure(v) => assert_eq!(v, 4u32), FreeTriv::Free(_) => unreachable!(), } - }, - FreeTriv::Pure(_) => unreachable!() + } + FreeTriv::Pure(_) => unreachable!(), } -} \ No newline at end of file +} -- cgit v1.2.3