Closed nulldatamap closed 9 years ago
The following code results in a misleading error message and is not intended behaviour.
pub struct Wowser<'a> { wow : &'a mut str, } impl<'a> Wowser<'a> { pub fn new( wowling : &'a mut str ) -> Wowser<'a> { Wowser{ wow: wowling } } }
Error:
error: mismatched types: expected `&mut str`, found `&'a mut str` (values differ in mutability) Wowser{ wow: wowling } ^~~~~~~
Passing a new lifetime to the function will result in the same error:
pub fn new<'b>( wowling : &'b mut str ) -> Wowser<'b> {
This example now compiles.
The following code results in a misleading error message and is not intended behaviour.
Error:
Passing a new lifetime to the function will result in the same error: