gitui/src/components/utils/emoji.rs
Jakub Jirutka fa7cd37ca7 Make gh-emoji optional
gh-emoji crate includes *images* of GitHub's emoji - this is quite a big
dependency. It increases the binary size by 1 MiB; that's +25 % when
building v0.18.0 on Alpine Linux with build flags to optimize size.
I consider it an unnecessary bloat that should be optional.
2021-11-10 18:07:48 +01:00

17 lines
394 B
Rust

use lazy_static::lazy_static;
use std::borrow::Cow;
lazy_static! {
static ref EMOJI_REPLACER: gh_emoji::Replacer =
gh_emoji::Replacer::new();
}
// Replace markdown emojis with Unicode equivalent
// :hammer: --> 🔨
#[inline]
pub fn emojifi_string(s: &mut String) {
let resulting_cow = EMOJI_REPLACER.replace_all(s);
if let Cow::Owned(altered_s) = resulting_cow {
*s = altered_s;
}
}