mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
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.
17 lines
394 B
Rust
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;
|
|
}
|
|
}
|