Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
//! I'm so sorry...

const WORD_REPLACE: [(&str, &str); 9] = [
("small", "smol"),
("cute", "kawaii~"),
("fluff", "floof"),
("love", "luv"),
("stupid", "baka"),
("idiot", "baka"),
("what", "nani"),
("meow", "nya~"),
("roar", "rawrr~"),
];

/// Replace certain words with uwuified equivalents, such as:
///
/// - `small` -> `smol`
/// - `cute` -> `kawaii~`
/// - `fluff` -> `floof`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be "fwoof"

/// - ...
///
/// # Example:
///
/// ```
/// use imsosorrybtw::replace_words;
/// let text = "small dogs";
/// let uwuified = replace_words(text);
///
/// assert_eq!(uwuified, "smol dogs");
/// ```
#[allow(clippy::doc_markdown)]
#[must_use]
pub fn replace_words(text: &str) -> String {
WORD_REPLACE
.iter()
.fold(text.to_string(), |acc, (word, replacement)| {
acc.replace(word, replacement)
})
}

/// Replace certain characters with their UwU equivalents:
///
/// - `r` -> `w`
/// - `l` -> `w`
/// - `n` -> `ny`
/// - `ove` -> `uv`
///
/// This will **NOT** account for capitalization.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove, still true

///
/// # Example
///
/// ```
Expand All @@ -32,10 +68,14 @@ pub fn char_replace(text: &str) -> String {
/// UwUify a string. This basically turns the text lowercase and applies every other function in
/// this crate to a string in order:
///
/// - `replace_words`
/// - `char_replace`
#[allow(clippy::doc_markdown)]
#[must_use]
pub fn uwuify(text: &str) -> String {
let text = text.to_lowercase();
char_replace(&text)
let mut text = text.to_lowercase();
text = replace_words(&text);
text = char_replace(&text);

text
}
14 changes: 1 addition & 13 deletions tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
//! Tests for the `imsosorrybtw` crate.
//! If you're apologizing, might as well do it properly!

use imsosorrybtw::{char_replace, uwuify};

/// Test the `char_replace` function.
#[test]
fn test_char_replace() {
// This test is the same as the example in the docs, but it's good to have
// it here as well.

let text = "I'm so sorry...";
let uwuified = char_replace(text);

assert_eq!(uwuified, "I'm so sowwy...");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHAT THE SIGMA, we don't delete tests in this household

use imsosorrybtw::uwuify;

/// Test if `uwuify` turns the text lowercase.
#[test]
Expand Down