E4018#
Cannot resolve trait for the given type.
Erroneous Example#
struct S { v : Int }
let s : S = { v: 3 }
let t = Show::to_string(s)
The example above tries to call the method to_string
from
the Show
trait on a type S
, but since S
does not implement
that trait, it gives the following error on line 4:
Type S does not implement trait Show: method output is missing
Suggestion#
Implement the Show
trait for the type S
:
struct S { v : Int }
let s : S = { v: 3 }
let t = Show::to_string(s)
impl Show for S with output(self, logger) {
logger.write_object(self.v)
}