pin-project-lite
pin-project-lite copied to clipboard
Support multiple trait bounds on generics and where clause
Workaround: https://github.com/taiki-e/pin-project-lite/issues/2#issuecomment-745190950
Currently, the following code does not be supported:
generics:
- [x]
?trait bounds: done in #9
pin_project! {
pub struct Maybe<'a, T: ?Sized> {
field: &'a mut T,
}
}
- [ ] multiple trait bounds:
pin_project! {
pub struct Multiple<'a, T: core::fmt::Debug + core::fmt::Display> {
field: &'a mut T,
}
}
where clause:
- [x]
?trait bounds: done in #22
pin_project! {
pub struct Maybe<'a, T>
where
T: ?Sized,
{
field: &'a mut T,
}
}
- [ ] multiple trait bounds:
pin_project! {
pub struct Multiple<'a, T>
where
T: core::fmt::Debug + core::fmt::Display
{
field: &'a mut T,
}
}
reference: https://doc.rust-lang.org/reference/trait-bounds.html#trait-and-lifetime-bounds
This is a bug, but maybe a limitation of declarative macros, and I'm not sure if it can be fully fixed.
? trait bounds are supported on both generics and where clause. (#9, #22)
Workaround: This can be avoided by moving bounds to where clause and splitting it.
pin_project! {
- pub struct Multiple<'a, T: core::fmt::Debug + core::fmt::Display> {
+ pub struct Multiple<'a, T: core::fmt::Debug>
+ where
+ T: core::fmt::Display,
{
field: &'a mut T,
}
}
pin_project! {
pub struct Multiple<'a, T>
where
- T: core::fmt::Debug + core::fmt::Display
+ T: core::fmt::Debug,
+ T: core::fmt::Display,
{
field: &'a mut T,
}
}