Content-Length: 24468 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../thread/../../../error_codes/./E0212.html

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

Cannot use the associated type of a trait with uninferred generic parameters.

Erroneous code example:

#![allow(unused)]
fn main() {
pub trait Foo<T> {
    type A;

    fn get(&self, t: T) -> Self::A;
}

fn foo2<I : for<'x> Foo<&'x isize>>(
    field: I::A) {} // error!
}

In this example, we have to instantiate 'x, and we don’t know what lifetime to instantiate it with. To fix this, spell out the precise lifetimes involved. Example:

#![allow(unused)]
fn main() {
pub trait Foo<T> {
    type A;

    fn get(&self, t: T) -> Self::A;
}

fn foo3<I : for<'x> Foo<&'x isize>>(
    x: <I as Foo<&isize>>::A) {} // ok!


fn foo4<'a, I : for<'x> Foo<&'x isize>>(
    x: <I as Foo<&'a isize>>::A) {} // ok!
}








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/../thread/../../../error_codes/./E0212.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy