Sometimes, functions can have the same names. Consider this code:

\begin{rustc}
trait Foo {
    fn f(&self);
}

trait Bar {
    fn f(&self);
}

struct Baz;

impl Foo for Baz {
    fn f(&self) { println!("Baz's impl of Foo"); }
}

impl Bar for Baz {
    fn f(&self) { println!("Baz's impl of Bar"); }
}

let b = Baz;
\end{rustc}

If we were to try to call \code{b.f()}, we'd get an error:

\begin{verbatim}
error: multiple applicable methods in scope [E0034]
b.f();
  ^~~
note: candidate #1 is defined in an impl of the trait `main::Foo` for the type
`main::Baz`
    fn f(&self) { println!("Baz's impl of Foo"); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: candidate #2 is defined in an impl of the trait `main::Bar` for the type
`main::Baz`
    fn f(&self) { println!("Baz's impl of Bar"); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\end{verbatim}

We need a way to disambiguate which method we need. This feature is called ‘universal function call syntax', and it looks like this:

\begin{rustc}
Foo::f(&b);
Bar::f(&b);
\end{rustc}

Let's break it down.

\begin{rustc}
Foo::
Bar::
\end{rustc}

These halves of the invocation are the types of the two traits: \code{Foo} and \code{Bar}. This is what ends up actually doing the 
disambiguation between the two: Rust calls the one from the trait name you use.

\begin{rustc}
f(&b)
\end{rustc}

When we call a method like \code{b.f()} using method syntax (see \nameref{sec:syntax_methodSyntax}), Rust will automatically borrow 
\code{b} if \code{f()} takes \code{\&self}. In this case, Rust will not, and so we need to pass an explicit \code{\&b}.

\subsection*{Angle-bracket Form}

The form of UFCS we just talked about:

\begin{rustc}
Trait::method(args);
\end{rustc}

Is a short-hand. There's an expanded form of this that's needed in some situations:

\begin{rustc}
<Type as Trait>::method(args);
\end{rustc}

The \code{<>::} syntax is a means of providing a type hint. The type goes inside the \code{<>}s. In this case, the type is 
\code{Type as Trait}, indicating that we want \code{Trait}'s version of \code{method} to be called here. The \code{as Trait} part 
is optional if it's not ambiguous. Same with the angle brackets, hence the shorter form.

\blank

Here's an example of using the longer form.

\begin{rustc}
trait Foo {
    fn foo() -> i32;
}

struct Bar;

impl Bar {
    fn foo() -> i32 {
        20
    }
}

impl Foo for Bar {
    fn foo() -> i32 {
        10
    }
}

fn main() {
    assert_eq!(10, <Bar as Foo>::foo());
    assert_eq!(20, Bar::foo());
}
\end{rustc}

Using the angle bracket syntax lets you call the trait method instead of the inherent one.
