ff

Macro ff 

Source
ff!() { /* proc-macro */ }
Expand description

Provide an alternative syntax to write Fully Qualified Syntax without nesting turbofishes.

The content of ff!(...) starts with the source type, followed by a chain of | Trait::Item, Trait being the trait containing Item associated type. Both Trait and Item can have generics. The last Item can also qualify an associated constant or function.

ยงExemple

Given the following traits and structs:

use flatfish::ff;

trait Level1 {
    type Foo<T>: Level2<T>;
}

trait Level2<T> {
    type Baz;
}

struct Impl1;
impl Level1 for Impl1 {
    type Foo<T> = Impl2;
}

struct Impl2;
impl<T> Level2<T> for Impl2 {
    type Baz = u32;
}

The following types are equivalent:

  • ff!(T | Level1::Foo<u32> | Level2<u32>::Baz)
  • <<T as Level1>::Foo<u32> as Level2<u32>>::Baz