#self-referential #words #string #finding #numbers #contain #description

carykh-macro-rust

A rust macro for finding strings that contain self-referential numbers. Inspired by carykh. This description contains twenty-seven words, fifty-four vowels, and ninety-nine consonants.

1 unstable release

0.1.2 Oct 14, 2024
0.1.1 Oct 14, 2024
0.1.0 Oct 14, 2024

#1086 in Rust patterns

Download history 377/week @ 2024-10-11 46/week @ 2024-10-18

423 downloads per month

MIT license

12KB
249 lines

A rust macro for finding strings that contain self-referential numbers. Inspired by carykh. This description contains twenty-seven words, fifty-four vowels, and ninety-nine consonants.

Usage

// This sentence has thirty-one letters.
let s = carykh_optimize!("This sentence has {} letters.", count_letters).unwrap();
println!("{}", s);

// This sentence has twenty-two vowels and thirty-eight consonants. Hooray!
let s = carykh_optimize!(
    "This sentence has {} vowels and {} consonants. Hooray!",
    count_vowels,
    count_consonants
)
.unwrap();
println!("{}", s);

// Number of words of each length in this bar graph:
// (three) two-letter-words,
// (three) three-letter-words,
// (five) four-letter-words,
// (eleven) five-letter-words,
// (eight) six-letter-words
let s = carykh_optimize!(
    "Number of words of each length in this bar graph:\n({}) two-letter-words,\n({}) three-letter-words,\n({}) four-letter-words,\n({}) five-letter-words,\n({}) six-letter-words",
    count_words_of_length_n(2),
    count_words_of_length_n(3),
    count_words_of_length_n(4),
    count_words_of_length_n(5),
    count_words_of_length_n(6)
).unwrap();
println!("{}", s);

// Number of vowels and consonants in this mesmerizing pie chart:
// Vowels: Thirty-Four percent
// Consonants: Sixty-Six percent
let s = carykh_optimize!(
    "Number of vowels and consonants in this mesmerizing pie chart\nVowels: {} percent\nConsonants: {} percent",
    count_vowels,
    count_consonants;
    {
        formatting = Formatting::all(),
        condition = has_n_letters(100)
    }
).unwrap();
println!("{}", s);

Dependencies

~21KB