fn prompt_once<R: BufRead, W: Write, T: FromStr>(
        &self,
        stream: &mut MenuStream<R, W>,
        fmt: &Format<'_>,
        opt: bool,
    ) -> MenuResult<Option<T>> {
        fn default_output<T: FromStr>(d: &str) -> T {
            d.parse().unwrap_or_else(|_| default_failed::<T>(d))
        }

        let s = self.prompt_line(stream, fmt, opt)?;

        if s.is_empty() {
            return Ok(self.default.as_deref().map(default_output));
        }

        let out = s
            .parse()
            .ok()
            .or_else(|| self.default.as_deref().map(default_output));

        Ok(out)
    }
/// Prompts the field once, using the given prefix.
///
/// It checks the `line_brk` specification. If it is on `true`, the suffix is displayed
/// on a separate line, thus it will only display the suffix. Otherwise, it prints out
/// the whole message with the suffix.
Prompts the field once, using the given prefix.
It checks the `line_brk` specification. If it is on `true`, the suffix is displayed
on a separate line, thus it will only display the suffix. Otherwise, it prints out
the whole message with the suffix.
Prompts the field once using the given prefix . It checks the ` line_brk ` specification . If it is on ` true ` the suffix is displayed on a separate line thus it will only display the suffix . Otherwise it prints out the whole message with the suffix .
fn prompt_once<R: BufRead, W: Write, T: FromStr>(
        &self,
        stream: &mut MenuStream<R, W>,
        fmt: &Format<'_>,
        opt: bool,
    ) -> MenuResult<Option<T>> {
        fn default_output<T: FromStr>(d: &str) -> T {
            d.parse().unwrap_or_else(|_| default_failed::<T>(d))
        }
        let s = self.prompt_line(stream, fmt, opt)?;
        if s.is_empty() {
            return Ok(self.default.as_deref().map(default_output));
        }
        let out = s
            .parse()
            .ok()
            .or_else(|| self.default.as_deref().map(default_output));
        Ok(out)
    }
fn prompt_once < R : BufRead , W : Write , T : FromStr > ( & self , stream : & mut MenuStream < R , W > , fmt : & Format < ' _ > , opt : bool , ) -> MenuResult < Option < T > > { fn default_output < T : FromStr > ( d : & str ) -> T { d . parse ( ) . unwrap_or_else ( | _ | default_failed :: < T > ( d ) ) } let s = self . prompt_line ( stream , fmt , opt ) ? ; if s . is_empty ( ) { return Ok ( self . default . as_deref ( ) . map ( default_output ) ) ; } let out = s . parse ( ) . ok ( ) . or_else ( | | self . default . as_deref ( ) . map ( default_output ) ) ; Ok ( out ) }
Prompts the field once, using the given prefix.
Prompts the field once using the given prefix .
&self
stream
&mut MenuStream<R, W>
fmt
&Format<'_>
opt
bool