pub trait ImpliedPredicate<T: ?Sized>: HasAssoc<T, Impls = T> { }
Expand description
Helper trait for the implied/entailed bounds trick.
§Usage:
When you have:
// this clause is not entailed
// vvvvvvvv
trait SomeTrait<T : Clone>
where
// And neither is this one.
Self::SomeGat<true> : Send,
{
type SomeGat<const IS_SEND: bool>;
// …
}
instead, write:
use ::implied_bounds::ImpliedPredicate;
trait SomeTrait<T>
:
ImpliedPredicate<T, Impls : Clone> +
ImpliedPredicate<Self::SomeGat<true>, Impls : Send> +
{
type SomeGat<const IS_SEND: bool>;
// …
}
§Convenience macro
Since this usage is not only not the most obvious to write, but more importantly, not very readable afterwards, this crate exposes a helper convenience macro which shall do this mechanical transformation in your stead; in an automated, reliable, and predictable manner.
use ::implied_bounds::implied_bounds;
#[implied_bounds] // 👈
trait SomeTrait<T : Clone>
where
Self::SomeGat<true> : Send,
{
type SomeGat<const IS_SEND: bool>;
// …
}
And voilà 😙👌