Content-Length: 24496 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../../std/../../../error_codes/./E0050.html

E0050 - Error codes index

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0050

An attempted implementation of a trait method has the wrong number of function parameters.

Erroneous code example:

#![allow(unused)]
fn main() {
trait Foo {
    fn foo(&self, x: u8) -> bool;
}

struct Bar;

// error: method `foo` has 1 parameter but the declaration in trait `Foo::foo`
// has 2
impl Foo for Bar {
    fn foo(&self) -> bool { true }
}
}

For example, the Foo trait has a method foo with two function parameters (&self and u8), but the implementation of foo for the type Bar omits the u8 parameter. To fix this error, they must have the same parameters:

#![allow(unused)]
fn main() {
trait Foo {
    fn foo(&self, x: u8) -> bool;
}

struct Bar;

impl Foo for Bar {
    fn foo(&self, x: u8) -> bool { // ok!
        true
    }
}
}








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../error/../string/../../std/../../../error_codes/./E0050.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy