fn prompt(&self) -> String {
        // In case of failure, use safe prompt. It is a closure so it is only allocated if it is
        // needed.
        let safe_prompt = || SAFE_PROMPT.to_string();

        let bufwtr = BufferWriter::stderr(ColorChoice::Always);
        let mut buffer = bufwtr.buffer();
        let mut color = ColorSpec::new();
        let mut bright_color = ColorSpec::new();
        bright_color.set_intense(true);

        // Create textual prompt.
        if buffer.set_color(color.set_fg(Some(Color::Green))).is_err() {
            return safe_prompt();
        }
        if write!(&mut buffer, "carapace").is_err() {
            println!("Failed to write to term!");
        }

        if let Ok(cwd) = env::current_dir() {
            if buffer
                .set_color(bright_color.set_fg(Some(Color::Blue)))
                .is_err()
            {
                return safe_prompt();
            }
            if write!(&mut buffer, " {}", cwd.display()).is_err() {
                println!("Failed to write to term!");
            }
        }

        if buffer.set_color(color.set_fg(Some(Color::Green))).is_err() {
            return safe_prompt();
        }

        let uid_ch = if UID_ROOT == unsafe { libc::geteuid() } {
            '#'
        } else {
            '%'
        };
        if write!(&mut buffer, " {} ", uid_ch).is_err() {
            println!("Failed to write to term!");
        }

        // Reset prompt color to white so colors don't flow into the cursor and
        // user commands.
        if buffer.set_color(color.set_fg(Some(Color::White))).is_err() {
            return safe_prompt();
        }

        String::from_utf8_lossy(&buffer.into_inner()).into_owned()
    }
/// Yields the textual prompt with term colors.
Yields the textual prompt with term colors.
Yields the textual prompt with term colors .
fn prompt(&self) -> String {
        // In case of failure, use safe prompt. It is a closure so it is only allocated if it is
        // needed.
        let safe_prompt = || SAFE_PROMPT.to_string();
        let bufwtr = BufferWriter::stderr(ColorChoice::Always);
        let mut buffer = bufwtr.buffer();
        let mut color = ColorSpec::new();
        let mut bright_color = ColorSpec::new();
        bright_color.set_intense(true);
        // Create textual prompt.
        if buffer.set_color(color.set_fg(Some(Color::Green))).is_err() {
            return safe_prompt();
        }
        if write!(&mut buffer, "carapace").is_err() {
            println!("Failed to write to term!");
        }
        if let Ok(cwd) = env::current_dir() {
            if buffer
                .set_color(bright_color.set_fg(Some(Color::Blue)))
                .is_err()
            {
                return safe_prompt();
            }
            if write!(&mut buffer, " {}", cwd.display()).is_err() {
                println!("Failed to write to term!");
            }
        }
        if buffer.set_color(color.set_fg(Some(Color::Green))).is_err() {
            return safe_prompt();
        }
        let uid_ch = if UID_ROOT == unsafe { libc::geteuid() } {
            '#'
        } else {
            '%'
        };
        if write!(&mut buffer, " {} ", uid_ch).is_err() {
            println!("Failed to write to term!");
        }
        // Reset prompt color to white so colors don't flow into the cursor and
        // user commands.
        if buffer.set_color(color.set_fg(Some(Color::White))).is_err() {
            return safe_prompt();
        }
        String::from_utf8_lossy(&buffer.into_inner()).into_owned()
    }
fn prompt ( & self ) -> String { // In case of failure, use safe prompt. It is a closure so it is only allocated if it is // needed. let safe_prompt = | | SAFE_PROMPT . to_string ( ) ; let bufwtr = BufferWriter :: stderr ( ColorChoice :: Always ) ; let mut buffer = bufwtr . buffer ( ) ; let mut color = ColorSpec :: new ( ) ; let mut bright_color = ColorSpec :: new ( ) ; bright_color . set_intense ( true ) ; // Create textual prompt. if buffer . set_color ( color . set_fg ( Some ( Color :: Green ) ) ) . is_err ( ) { return safe_prompt ( ) ; } if write ! ( mut buffer " " ) . is_err ( ) { println ! ( " " ) ; } if let Ok ( cwd ) = env :: current_dir ( ) { if buffer . set_color ( bright_color . set_fg ( Some ( Color :: Blue ) ) ) . is_err ( ) { return safe_prompt ( ) ; } if write ! ( mut buffer " " cwd display ( ) ) . is_err ( ) { println ! ( " " ) ; } } if buffer . set_color ( color . set_fg ( Some ( Color :: Green ) ) ) . is_err ( ) { return safe_prompt ( ) ; } let uid_ch = if UID_ROOT == unsafe { libc :: geteuid ( ) } { '#' } else { '%' } ; if write ! ( mut buffer " " uid_ch ) . is_err ( ) { println ! ( " " ) ; } // Reset prompt color to white so colors don't flow into the cursor and // user commands. if buffer . set_color ( color . set_fg ( Some ( Color :: White ) ) ) . is_err ( ) { return safe_prompt ( ) ; } String :: from_utf8_lossy ( & buffer . into_inner ( ) ) . into_owned ( ) }
Yields the textual prompt with term colors.
Yields the textual prompt with term colors .
&self