Skip to content

Instantly share code, notes, and snippets.

@YoshiTheChinchilla
Last active June 3, 2020 08:59
Show Gist options
  • Save YoshiTheChinchilla/5134cf107e91ad9e7521a6c47db1dfed to your computer and use it in GitHub Desktop.
Save YoshiTheChinchilla/5134cf107e91ad9e7521a6c47db1dfed to your computer and use it in GitHub Desktop.
A ChiGyu (cheese gyūdon), Japanese internet meme library written in Rust
[package]
name = "chigyu"
version = "0.1.0"
authors = ["Takashi Yoshimura"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "chigyu"
path = "lib.rs"
// ChiGyu Links
// Gyūdon Wikipedia: https://en.wikipedia.org/wiki/Gyūdon
// Cheese Gyūdon in Sukiya: https://www.sukiya.jp/menu/in/gyudon/102900/
// Gyudon with 3 Cheeses: https://www.sukiya.jp/en/#menu
// Related Tweets
// The chigyu image author's tweet: https://twitter.com/ibiryo_sun/status/1055112055856873472
// ChiGyu faces: https://twitter.com/eightbridges_88/status/1252038939319267328
// The ChiGyu Walk: https://twitter.com/iden_8321/status/1265331386761633797
// cargo add chigyu --git https://gist.github.com/YoshiTheChinchilla/5134cf107e91ad9e7521a6c47db1dfed
// Or use this text of a dependency: chigyu = { git = "https://gist.github.com/YoshiTheChinchilla/5134cf107e91ad9e7521a6c47db1dfed" }
pub struct ChiGyu;
impl ChiGyu {
pub fn order() {
println!("{}", Self::sentence());
}
pub fn sentence() -> String {
"すいません。\n三色チーズ牛丼の特盛に温玉付きをお願いします。".into()
}
pub fn dummy_words(count: usize, words: &str) -> String {
assert!(count > 0);
assert!(words != "");
let mut buf = std::collections::VecDeque::with_capacity(count * 2 + 1);
buf.push_front(words);
(0..count).for_each(|_| { buf.push_front("チー牛「"); buf.push_back("」"); });
Vec::from(buf).join("")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_dummy_words() {
assert_eq!(ChiGyu::dummy_words(1, "チー牛かわいい"), "チー牛「チー牛かわいい」");
assert_eq!(ChiGyu::dummy_words(2, "チー牛は良い奴"), "チー牛「チー牛「チー牛は良い奴」」");
assert_eq!(ChiGyu::dummy_words(10, "チー牛きもい"), "チー牛「チー牛「チー牛「チー牛「チー牛「チー牛「チー牛「チー牛「チー牛「チー牛「チー牛きもい」」」」」」」」」」");
}
#[test]
#[should_panic]
fn test_panic_dummy_words() {
ChiGyu::dummy_words(0, "三色チーズ牛丼");
ChiGyu::dummy_words(10, "");
}
}
/*
The MIT License (MIT)
Copyright (c) 2020 Takashi Yoshimura
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment