[SOLVED] Error with using Option in a Struct


#1

Hello guys, I am a newbie rustacean and I need your help. I do not understannd why is the following error appearing:

https://is.gd/29I8cH


#2

Because you’re giving it a None, rustc can’t figure out which type the P in Option<P> is.

You could write something like:

let opt: Option<&str> = None;
let a = Sample::new(opt);

or shorter:

let a = Sample::new(None::<&str>);

#3

Thank you! I couldn’t figure it out.