diff options
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 14 |
3 files changed, 10 insertions, 12 deletions
@@ -1,9 +1,4 @@ [[package]] -name = "Inflector" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "chrono" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -45,7 +40,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "primstav" version = "0.1.0" dependencies = [ - "Inflector 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -109,7 +103,6 @@ dependencies = [ ] [metadata] -"checksum Inflector 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4467f98bb61f615f8273359bf1c989453dfc1ea4a45ae9298f1dcd0672febe5d" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" @@ -6,5 +6,4 @@ edition = "2018" [dependencies] chrono = "0.4.6" -Inflector = {version = "0.11.3", default-features=false } # We don't need pluralization etc serde_yaml = "0.8.8" diff --git a/src/main.rs b/src/main.rs index c4996f5..8f5f038 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,6 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. use chrono; -use inflector::Inflector; use serde_yaml; use std::io::BufReader; use std::iter::Iterator; @@ -23,13 +22,20 @@ use std::fs::File; use std::str::FromStr; use std::string::ToString; +fn capitalize(s: &str) -> String { + match s.chars().next() { + Some(ch) => ch.to_uppercase().collect::<String>() + &s[1..], + None => String::new(), + } +} + fn print_entry(d: &serde_yaml::Value) { let name = d.get("name").unwrap(); - println!("{}", name.as_str().unwrap().to_sentence_case()); + println!("{}", capitalize(name.as_str().unwrap())); if let Some(alt_names) = d.get("alternative_names") { let names = alt_names.as_sequence().unwrap().iter() - .map(|v| v.as_str().unwrap().to_title_case()) + .map(|v| capitalize(v.as_str().unwrap())) .collect::<Vec<_>>(); println!("({})", names.join(", ")); } @@ -52,7 +58,7 @@ fn main() { None => chrono::Local::today().naive_utc(), }; - println!("{}", local_date.format("%A %d. %b, %Y")); + println!("{}", capitalize(&local_date.format("%A %d. %b, %Y").to_string())); let key = local_date.format("%d%m").to_string(); match data.get(serde_yaml::Value::Number(u32::from_str(&key).unwrap().into())) { |