In the example above I have to specify that T must implement the Foo twice, which is not really handy when a constraint is more complicated. Is it possible to avoid this and specify the constraint only once?
Normally the answer would be "just don't specify it on the struct, and only on the impl block" like this:
struct Bar<T> {
foo: T,
foobar: T::FooBar,
}
But this doesn't work when you want to use an associated type such as T::FooBar. There's no way to avoid it, other than having two generic arguments like you've already figured out. That said, you could write your second example like this:
One solution to this that is in the works (i. e. exists an unstable feature on nightly) is a feature for defining a short alias for a lengthy constraint.