Use frunk v0.3.1

This commit is contained in:
Temirkhan Myrzamadi 2020-07-28 20:58:23 +06:00
parent 709fe18ade
commit 3a0a005265
2 changed files with 6 additions and 5 deletions

View file

@ -53,7 +53,7 @@ serde_with_macros = "1.1.0"
redis = { version = "0.16.0", optional = true }
serde_cbor = { version = "0.11.1", optional = true }
bincode = { version = "1.3.1", optional = true }
frunk = { git = "https://github.com/Hirrolot/frunk", branch = "append-to-hlist", optional = true }
frunk = { version = "0.3.1", optional = true }
teloxide-macros = "0.3.2"

View file

@ -1,6 +1,7 @@
#![cfg(feature = "frunk")]
use frunk::{from_generic, generic::Generic, hlist::HAppender, into_generic};
use frunk::{from_generic, generic::Generic, hlist::h_cons, into_generic, HCons, HNil};
use std::ops::Add;
/// Constructs a structure from another structure and a field.
///
@ -14,10 +15,10 @@ pub trait UpState: Sized {
fn up<T1, T1Repr, F>(src: T1, field: F) -> Self
where
T1: Generic<Repr = T1Repr>,
Self: Generic<Repr = <T1Repr as HAppender<F>>::Output>,
T1Repr: HAppender<F>,
Self: Generic<Repr = <T1Repr as Add<HCons<F, HNil>>>::Output>,
T1Repr: Add<HCons<F, HNil>>,
{
from_generic(into_generic(src).append(field))
from_generic(into_generic(src) + h_cons(field, HNil))
}
}