This is how rustfmt formats a long list of type parameter bounds featuring a long list of bracketed generic arguments:
type ProposeTransactionsFuture: Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
> + Send
+ 'static;
The first bound after the closing bracket is formatted inline and is visually obscured.
It would be better to break and align the top-level + separators:
type ProposeTransactionsFuture: Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
>
+ Send
+ 'static;
Edit: Or better yet, on suggestion by @topecongiro below:
type ProposeTransactionsFuture:
Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
>
+ Send
+ 'static;
Can you share the snippet where this appears in ?
Here's a self-sufficient code snippet:
use futures::future::Future;
struct Error;
struct ProposeTransactionsResponse<Id> {
id: Id,
}
trait Service {
type MessageId;
type ProposeTransactionsFuture: Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
> + Send
+ 'static;
}
In addition to @mzabaluev's comment, I think that we shouldn't put the Future on the same line as type. Specifically, if the generic bounds span to multiple lines, then we should put them on the next line with additional indentation:
trait Service {
type MessageId;
type ProposeTransactionsFuture:
Future<Item = ProposeTransactionsResponse<Self::MessageId>, Error = Error>
+ Send
+ 'static;
type ProposeTransactionsFuture:
Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
AnotherItem = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
>
+ Send
+ 'static;
}
@topecongiro The indentation in your snippet looks inconsistent. I would prefer all bound lines to be aligned on the same level:
trait Service {
type MessageId;
type ProposeTransactionsFuture:
Future<Item = ProposeTransactionsResponse<Self::MessageId>, Error = Error>
+ Send
+ 'static;
type ProposeTransactionsFuture:
Future<
Item = ProposeTransactionsResponse<Self::MessageId>,
AnotherItem = ProposeTransactionsResponse<Self::MessageId>,
Error = Error,
>
+ Send
+ 'static;
}
@mzabaluev I agree with you.