Content-Length: 24480 | pFad | https://doc.rust-lang.org/std/string/../hash/../../std/string/../../std/../error_codes/./E0049.html

E0049 - 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 E0049

An attempted implementation of a trait method has the wrong number of type or const parameters.

Erroneous code example:

#![allow(unused)]
fn main() {
trait Foo {
    fn foo<T: Default>(x: T) -> Self;
}

struct Bar;

// error: method `foo` has 0 type parameters but its trait declaration has 1
// type parameter
impl Foo for Bar {
    fn foo(x: bool) -> Self { Bar }
}
}

For example, the Foo trait has a method foo with a type parameter T, but the implementation of foo for the type Bar is missing this parameter. To fix this error, they must have the same type parameters:

#![allow(unused)]
fn main() {
trait Foo {
    fn foo<T: Default>(x: T) -> Self;
}

struct Bar;

impl Foo for Bar {
    fn foo<T: Default>(x: T) -> Self { // ok!
        Bar
    }
}
}








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/../hash/../../std/string/../../std/../error_codes/./E0049.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy