From 85043c4a3e0b56c76d871658b9b6a9eebad8036c Mon Sep 17 00:00:00 2001 From: Compey Date: Wed, 6 Sep 2023 13:05:18 +0530 Subject: [PATCH] refactor: modernize codebase for rust edition 2021 --- Cargo.toml | 2 +- README.md | 14 +++++++------- build.rs | 7 +------ src/lib.rs | 11 +++-------- tests/de.rs | 5 +---- tests/en.rs | 5 +---- tests/es.rs | 5 +---- tests/fr.rs | 5 +---- tests/it.rs | 5 +---- tests/ja.rs | 5 +---- tests/pl.rs | 5 +---- tests/pt-br.rs | 5 +---- tests/pt.rs | 5 +---- tests/tr.rs | 5 +---- 14 files changed, 22 insertions(+), 62 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 598c7dc..266c54a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "chrono_locale" +name = "chrono_lc" version = "0.1.2" edition = "2021" authors = ["Alessandro Pellizzari ", "Erica Marigold "] diff --git a/README.md b/README.md index 2aadcad..2e93e86 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,14 @@ Put this in your Cargo.toml: ```toml [dependencies] chrono = "0.4.56" -chrono_locale = { git = "https://github.com/0x5eal/chrono-locale.git", tag = "v0.1.2" } +chrono_lc = "0.1.2" ``` Then put this in your `lib.rs` or `main.rs`: ```rs use chrono::prelude::*; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; ``` You can choose to import just parts of chrono instead of the whole prelude. @@ -26,11 +26,11 @@ To format a chrono `Date` or `DateTime` object, you can use the `formatl` method ```rs let dt = FixedOffset::east_opt(34200) - .unwrap() - .with_ymd_and_hms(2001, 7, 8, 0, 34, 59) - .unwrap() - .with_nanosecond(1_026_490_708) - .unwrap(); + .unwrap() + .with_ymd_and_hms(2001, 7, 8, 0, 34, 59) + .unwrap() + .with_nanosecond(1_026_490_708) + .unwrap(); println!("{}", dt.formatl("%c", "fr")); ``` diff --git a/build.rs b/build.rs index f2c6246..e6985e5 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,4 @@ -extern crate serde; -extern crate walkdir; -#[macro_use] -extern crate serde_derive; -extern crate serde_json; - +use serde_derive::Deserialize; use serde_json::Error as JsonError; use std::env; use std::fs::File; diff --git a/src/lib.rs b/src/lib.rs index 7faaaac..8edcd55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,17 +8,14 @@ //! ```toml //! [dependencies] //! chrono = "0.4" -//! chrono_locale = { git = "https://github.com/0x5eal/chrono-locale.git", tag = "v0.1.2" } +//! chrono_lc = "0.1.2" //! ``` //! //! Then put this in your `lib.rs` or `main.rs`: //! //! ```rust -//! extern crate chrono; -//! extern crate chrono_locale; -//! //! use chrono::prelude::*; -//! use chrono_locale::LocaleDate; +//! use chrono_lc::LocaleDate; //! ``` //! //! You can choose to import just parts of chrono instead of the whole prelude. @@ -28,7 +25,7 @@ //! //! ```rust //! # use chrono::prelude::*; -//! # use chrono_locale::LocaleDate; +//! # use chrono_lc::LocaleDate; //! //! let dt = FixedOffset::east_opt(34200) //! .unwrap() @@ -60,8 +57,6 @@ #[macro_use] extern crate lazy_static; -extern crate chrono; -extern crate num_integer; use std::collections::HashMap; use std::fmt; diff --git a/tests/de.rs b/tests/de.rs index 0d38c52..36bdf17 100644 --- a/tests/de.rs +++ b/tests/de.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/en.rs b/tests/en.rs index 3e43fb3..37d137f 100644 --- a/tests/en.rs +++ b/tests/en.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/es.rs b/tests/es.rs index 09b84e8..9f38526 100644 --- a/tests/es.rs +++ b/tests/es.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/fr.rs b/tests/fr.rs index e0c704e..3d58759 100644 --- a/tests/fr.rs +++ b/tests/fr.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/it.rs b/tests/it.rs index df3d4dc..cf59570 100644 --- a/tests/it.rs +++ b/tests/it.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/ja.rs b/tests/ja.rs index 7d1c55f..85ed39d 100644 --- a/tests/ja.rs +++ b/tests/ja.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/pl.rs b/tests/pl.rs index ed4abc3..10af0d9 100644 --- a/tests/pl.rs +++ b/tests/pl.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/pt-br.rs b/tests/pt-br.rs index f461f95..332318c 100644 --- a/tests/pt-br.rs +++ b/tests/pt-br.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/pt.rs b/tests/pt.rs index b36b6cb..98e0878 100644 --- a/tests/pt.rs +++ b/tests/pt.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test] diff --git a/tests/tr.rs b/tests/tr.rs index 85dbd68..a1fd414 100644 --- a/tests/tr.rs +++ b/tests/tr.rs @@ -1,8 +1,5 @@ -extern crate chrono; -extern crate chrono_locale; - use chrono::{FixedOffset, TimeZone, Timelike}; -use chrono_locale::LocaleDate; +use chrono_lc::LocaleDate; // This test is copied from chrono's, disabling unsupported features #[test]