Debian Codegraph @

third_party/rust/darling/tests/custom_bound.rs

raw
1 #![allow(dead_code)]
2
3 use std::ops::Add;
4
5 use darling::{FromDeriveInput, FromMeta};
6
7 #[derive(Debug, Clone, FromMeta)]
8 #[darling(bound = "T: FromMeta + Add")]
9 struct Wrapper<T>(pub T);
10
11 impl<T: Add> Add for Wrapper<T> {
12 type Output = Wrapper<<T as Add>::Output>;
13 fn add(self, rhs: Self) -> Wrapper<<T as Add>::Output> {
14 Wrapper(self.0 + rhs.0)
15 }
16 }
17
18 #[derive(Debug, FromDeriveInput)]
19 #[darling(attributes(hello), bound = "Wrapper<T>: Add, T: FromMeta")]
20 struct Foo<T> {
21 lorem: Wrapper<T>,
22 }
23
24 #[test]
25 fn expansion() {}