// The following should be equivalent:
trait Foo {
type Bar<B: SomeBound>: OtherBound;
}
trait Foo where for<B: SomeBound> Self::Bar<B>: OtherBound {
type Bar<B> where B: SomeBound;
trait Iterator {
type Item<'a> where Self: 'a;
fn next<'a>(&'a mut self) -> Self::Item<'a>;
pub trait ValueTree {
type Value<'a>: fmt::Debug where Self: 'a;
fn current<'a>(&'a self) -> Self::Value<'a>;
fn simplify(&mut self) -> bool;
fn complicate(&mut self) -> bool;
pub trait Strategy: fmt::Debug {
/// The value tree generated by this `Strategy`.
type Tree: ValueTree<Value = Self::Value>;
/// The type of value used by functions under test generated by this Strategy.
type Value<'a>: fmt::Debug;
/// Generate a new value tree from the given runner.
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>;
Limitations re. bounds & constraints
// The following should be equivalent:
trait Foo {
type Bar<B: SomeBound>: OtherBound;
}
trait Foo where for<B: SomeBound> Self::Bar<B>: OtherBound {
type Bar<B> where B: SomeBound;
}
Motivations
Example use cases
Simple lifetime-parametric types
trait Iterator {
type Item<'a> where Self: 'a;
fn next<'a>(&'a mut self) -> Self::Item<'a>;
}
pub trait ValueTree {
type Value<'a>: fmt::Debug where Self: 'a;
fn current<'a>(&'a self) -> Self::Value<'a>;
fn simplify(&mut self) -> bool;
fn complicate(&mut self) -> bool;
}
pub trait Strategy: fmt::Debug {
/// The value tree generated by this `Strategy`.
type Tree: ValueTree<Value = Self::Value>;
/// The type of value used by functions under test generated by this Strategy.
type Value<'a>: fmt::Debug;
/// Generate a new value tree from the given runner.
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>;
}