What does `impl … for` mean?

impl Struct ... adds some methods to Struct. These methods aren’t available to other types or traits.

impl Trait for Struct .. implements the trait Trait for the struct Struct. This results in the methods of the trait being available for Struct.

So, even though these two syntaxes look similar, they do 2 completely different things.
impl Struct ... adds new (not previously defined) methods to the type, while the other adds previously defined methods (from the trait) to the type.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)