Wpis z mikrobloga

readline według dokumentacji:
pub fn readline(&self, buf : &mut String) -> io::Result

Czemu nie mogę skorzystać z takiej formy?
io::stdin().read
line(&mut usr_input)?;

Kompilator daje sprzeczne sygnały albo czegoś tu nie rozumiem: „the „?” operator can only be used in function that returns ‚Result’ or blablabla” a niżej „cannot use ? operator in function that returns ‚()’
#naukaprogramowania #rustlang #programowanie
  • 4
The ? is shorthand for the entire match statements we wrote earlier. In other words, ? applies to a Result value, and if it was an Ok, it unwraps it and gives the inner value. If it was an Err, it returns from the function you're currently in


@m504: @Hauleth: No tak, teraz to ma sens. Dzięki ( ͡° ͜ʖ ͡°)