Skip to main content

replace

Function replace 

Source
pub fn replace(
    text: &str,
    default_variant: Option<EmojiVariant>,
) -> Cow<'_, str>
Expand description

Replace Rich-style emoji codes in text.

Matches Python Rich’s behavior:

  • :smile: is replaced if the emoji exists (lookup uses lowercased name).
  • Optional variants: :smile-emoji: / :smile-text: append U+FE0F / U+FE0E.
  • Unknown emoji codes are left unchanged.
  • If default_variant is provided, it applies when no explicit variant is present.