promptt 1.1.0

Interactive CLI prompts library, lightweight and easy to use.
Documentation
//! Prompt output styling: delimiters.

use crate::util::figures::Figures;
use colour::write_gray;
use std::io::Write;

/// Returns delimiter between message and input (ellipsis when completing, pointer otherwise).
pub fn delimiter(completing: bool) -> String {
    let fig = Figures::default();
    let d = if completing {
        fig.ellipsis
    } else {
        fig.pointer_small
    };
    let mut buf = Vec::with_capacity(8);
    write_gray!(&mut buf, "{}", d).ok();
    String::from_utf8_lossy(&buf).into_owned()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn delimiter_completing_and_not_differ() {
        let d_false = delimiter(false);
        let d_true = delimiter(true);
        assert!(!d_false.is_empty());
        assert!(!d_true.is_empty());
    }
}