cryptan 0.4.2

A simple crypto playground (Caesar, Morse, ...).
Documentation
use std::fmt::{Display, Formatter, Result as FmtResult};
use colored::*;

#[derive(Debug)]
pub struct DecodedResult {
    pub text: String,
    pub key: u8,
    pub meaningful_ratio: Option<f32>,
}

impl Display for DecodedResult {
    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
        let key_str = format!("{}", self.key).bright_blue();
        let text_str = &self.text.green();
        if let Some(ratio) = self.meaningful_ratio {
            let ratio_str = format!("{:.2}", ratio).yellow();
            write!(f, "[Key: {}, meaningful Ratio: {}] {}", key_str, ratio_str, text_str)
        } else {
            write!(f, "[Key: {}] {}", key_str, text_str)
        }
    }
}