Skip to content

book: 'Angle-bracket Form' does not explain why expanded form is needed #29493

Closed
@ivan

Description

@ivan

https://doc.rust-lang.org/book/ufcs.html#angle-bracket-form gives an example that uses <Bar as Clone>::clone(self);, where using Clone::clone(self); works just as well (tested: rustc 1.6.0-nightly (2e07996 2015-10-29)). And therefore I have no idea why and where I'd need the longer form.

I tested

trait Foo {
    fn clone(&self);
}

#[derive(Clone)]
struct Bar;

impl Foo for Bar {
    fn clone(&self) {
        println!("Making a clone of Bar");

        //<Bar as Clone>::clone(self);
        Clone::clone(self);
    }
}

fn main() {
   let b = Bar;
   Foo::clone(&b);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions