From 7b0151088d9e0f8a684d3f4bebf637afd87c34fb Mon Sep 17 00:00:00 2001 From: tiye Date: Mon, 29 May 2023 00:53:49 +0800 Subject: [PATCH 1/2] upgrade to calcit 0.7 ; tag 0.1.0 --- .github/workflows/check.yaml | 8 +-- Cargo.lock | 99 +++++++++++++++++++++--------------- Cargo.toml | 12 ++--- calcit.cirru | 24 +++++---- compact.cirru | 18 +++---- src/date.rs | 36 ++++++------- src/json.rs | 10 ++-- 7 files changed, 116 insertions(+), 91 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index f183479..12bb2ae 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -21,15 +21,15 @@ jobs: - uses: supplypike/setup-bin@v3 with: - uri: "https://github.com/calcit-lang/calcit/releases/download/0.6.26/cr" + uri: "https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/cr" name: "cr" - version: "0.6.26" + version: "0.7.0-a3" - uses: supplypike/setup-bin@v3 with: - uri: "https://github.com/calcit-lang/calcit/releases/download/0.6.26/caps" + uri: "https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/caps" name: "caps" - version: "0.6.26" + version: "0.7.0-a3" - run: cargo build --release diff --git a/Cargo.lock b/Cargo.lock index 599cd2d..eaba91a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,9 +60,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "cirru_edn" -version = "0.2.21" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c8eadc7d7e440b6e2dce8b6ef16e688dc1a36dfcac8a627a1e769672664955" +checksum = "37f78b9daa64e28a97fb4879b9d3a3c4c0c50ad8e14698a6a4fb9db9868bfd43" dependencies = [ "cirru_parser", "hex", @@ -108,9 +108,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "ctrlc" -version = "3.2.4" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1631ca6e3c59112501a9d87fd86f21591ff77acd31331e8a73f8d80a65bbdd71" +checksum = "7394a21d012ce5c850497fb774b167d81b99f060025fbf06ee92b9848bd97eb2" dependencies = [ "nix", "windows-sys", @@ -140,7 +140,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.107", ] [[package]] @@ -157,7 +157,7 @@ checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -312,18 +312,18 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -381,29 +381,29 @@ checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.18", ] [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -427,6 +427,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -461,12 +472,11 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -497,7 +507,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -519,7 +529,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -563,9 +573,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -578,42 +597,42 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml index a6c592d..ee2d7e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,16 @@ crate-type = ["dylib"] # Creates dynamic lib # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -serde = { version = "1.0.152", features = ["derive"] } -serde_json = "1.0.91" -chrono = "0.4.23" -cirru_edn = "0.2.21" +serde = { version = "1.0.163", features = ["derive"] } +serde_json = "1.0.96" +chrono = "0.4.24" +cirru_edn = "0.4.0" cirru_parser = "0.1.24" nanoid = "0.4.0" rand = "0.8.5" -ctrlc = "3.2.4" +ctrlc = "3.3.1" md5 = "0.7.0" -walkdir = "2" +walkdir = "2.3.3" glob = "0.3.0" # [profile.release] diff --git a/calcit.cirru b/calcit.cirru index a6b45ce..5b2ceb1 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -1,6 +1,6 @@ {} - :configs $ {} (:init-fn |calcit.std.test/main!) (:port 6001) (:reload-fn |calcit.std.test/reload!) (:version |0.0.20) + :configs $ {} (:init-fn |calcit.std.test/main!) (:port 6001) (:reload-fn |calcit.std.test/reload!) (:version |0.1.0) :modules $ [] :entries $ {} :ir $ {} (:package |calcit.std) @@ -55,8 +55,9 @@ |r $ {} (:at 1636966247454) (:by |u0) (:text |k) (:type :leaf) |v $ {} (:at 1636967728074) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636967728711) (:by |u0) (:text |::) (:type :leaf) + |D $ {} (:at 1685292572645) (:by |u0) (:text |%::) (:type :leaf) |L $ {} (:at 1636967729484) (:by |u0) (:text |Date) (:type :leaf) + |P $ {} (:at 1685292574826) (:by |u0) (:text |:date) (:type :leaf) |T $ {} (:at 1636966254514) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1636966254514) (:by |u0) (:text |&call-dylib-edn) (:type :leaf) @@ -126,7 +127,7 @@ |f $ {} (:at 1636792866663) (:by |u0) (:text |d) (:type :leaf) |v $ {} (:at 1636968106841) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636968108910) (:by |u0) (:text |key-match) (:type :leaf) + |D $ {} (:at 1685292757658) (:by |u0) (:text |tag-match) (:type :leaf) |T $ {} (:at 1636792859991) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1636792859991) (:by |u0) (:text |&call-dylib-edn) (:type :leaf) @@ -146,8 +147,9 @@ |j $ {} (:at 1636968113748) (:by |u0) (:text |d) (:type :leaf) |j $ {} (:at 1636968114228) (:by |u0) (:type :expr) :data $ {} - |T $ {} (:at 1636968115037) (:by |u0) (:text |::) (:type :leaf) + |T $ {} (:at 1685292532289) (:by |u0) (:text |%::) (:type :leaf) |j $ {} (:at 1636968116179) (:by |u0) (:text |Date) (:type :leaf) + |n $ {} (:at 1685292535029) (:by |u0) (:text |:date) (:type :leaf) |r $ {} (:at 1636968116550) (:by |u0) (:text |d) (:type :leaf) |r $ {} (:at 1636968117650) (:by |u0) (:type :expr) :data $ {} @@ -193,7 +195,7 @@ |r $ {} (:at 1636792882847) (:by |u0) (:text |d) (:type :leaf) |v $ {} (:at 1636967753455) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636968331740) (:by |u0) (:text |key-match) (:type :leaf) + |D $ {} (:at 1685292761880) (:by |u0) (:text |tag-match) (:type :leaf) |T $ {} (:at 1636792882847) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1636792882847) (:by |u0) (:text |&call-dylib-edn) (:type :leaf) @@ -213,8 +215,9 @@ |j $ {} (:at 1636968335770) (:by |u0) (:text |d) (:type :leaf) |j $ {} (:at 1636968336677) (:by |u0) (:type :expr) :data $ {} - |T $ {} (:at 1636968337050) (:by |u0) (:text |::) (:type :leaf) + |T $ {} (:at 1685292540377) (:by |u0) (:text |%::) (:type :leaf) |b $ {} (:at 1636968345339) (:by |u0) (:text |Date) (:type :leaf) + |f $ {} (:at 1685292542748) (:by |u0) (:text |:date) (:type :leaf) |j $ {} (:at 1636968338015) (:by |u0) (:text |d) (:type :leaf) |r $ {} (:at 1636968346328) (:by |u0) (:type :expr) :data $ {} @@ -257,8 +260,9 @@ :data $ {} |v $ {} (:at 1636967668354) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636967669122) (:by |u0) (:text |::) (:type :leaf) + |D $ {} (:at 1685292584740) (:by |u0) (:text |%::) (:type :leaf) |L $ {} (:at 1636967678741) (:by |u0) (:text |Date) (:type :leaf) + |P $ {} (:at 1685292586795) (:by |u0) (:text |:date) (:type :leaf) |T $ {} (:at 1633168770408) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1633253286256) (:by |u0) (:text |&call-dylib-edn) (:type :leaf) @@ -297,8 +301,9 @@ |j $ {} (:at 1633181255231) (:by |u0) (:text |format) (:type :leaf) |v $ {} (:at 1636967697950) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636967699374) (:by |u0) (:text |::) (:type :leaf) + |D $ {} (:at 1685292595409) (:by |u0) (:text |%::) (:type :leaf) |L $ {} (:at 1636967700672) (:by |u0) (:text |Date) (:type :leaf) + |P $ {} (:at 1685292597705) (:by |u0) (:text |:date) (:type :leaf) |T $ {} (:at 1633181255929) (:by |u0) (:type :expr) :data $ {} |T $ {} (:at 1633253289856) (:by |u0) (:text |&call-dylib-edn) (:type :leaf) @@ -1250,8 +1255,9 @@ |T $ {} (:at 1633181525316) (:by |u0) (:text |format-time) (:type :leaf) |j $ {} (:at 1636967839382) (:by |u0) (:type :expr) :data $ {} - |D $ {} (:at 1636967840173) (:by |u0) (:text |::) (:type :leaf) + |D $ {} (:at 1685292559916) (:by |u0) (:text |%::) (:type :leaf) |L $ {} (:at 1636967840920) (:by |u0) (:text |Date) (:type :leaf) + |P $ {} (:at 1685292562723) (:by |u0) (:text |:date) (:type :leaf) |T $ {} (:at 1633181525316) (:by |u0) (:text |1417176009000) (:type :leaf) |r $ {} (:at 1633181525316) (:by |u0) (:text "||%Y-%m-%d %H:%M:%S %z") (:type :leaf) |yT $ {} (:at 1636560373324) (:by |u0) (:type :expr) diff --git a/compact.cirru b/compact.cirru index 9066e98..5c5715e 100644 --- a/compact.cirru +++ b/compact.cirru @@ -1,6 +1,6 @@ {} (:package |calcit.std) - :configs $ {} (:init-fn |calcit.std.test/main!) (:reload-fn |calcit.std.test/reload!) (:version |0.0.20) + :configs $ {} (:init-fn |calcit.std.test/main!) (:reload-fn |calcit.std.test/reload!) (:version |0.1.0) :modules $ [] :entries $ {} :files $ {} @@ -10,7 +10,7 @@ defrecord! Date (:now get-time!) (:parse parse-time) (:timestamp get-timestamp) (:add add-duration) (:format format-time) (:from-ymd from-ymd) (:from-ywd from-ywd) (:extract extract-time) |add-duration $ quote defn add-duration (date n k) - :: Date $ &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"add_duration" (nth date 1) n k + %:: Date :date $ &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"add_duration" (nth date 1) n k |extract-time $ quote defn extract-time (x) &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"extract_time" $ nth x 1 @@ -19,31 +19,31 @@ &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"format_time" (nth time 1) format |from-ymd $ quote defn from-ymd (y m d) - key-match + tag-match &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"from_ymd" y m d - (:single d) (:: Date d) + (:single d) (%:: Date :date d) (:ambiguous a b) raise $ str "\"ambiguous: " a "\" " b (:none) (raise "\"cannot construct") _ $ raise "\"unreachable!" |from-ywd $ quote defn from-ywd (y w d) - key-match + tag-match &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"from_ywd" y w d - (:single d) (:: Date d) + (:single d) (%:: Date :date d) (:ambiguous a b) raise $ str "\"ambiguous: " a "\" " b (:none) (raise "\"cannot construct") _ $ raise "\"unreachable!" |get-time! $ quote - defn get-time! () $ :: Date + defn get-time! () $ %:: Date :date &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"now_bang" |get-timestamp $ quote defn get-timestamp (date) &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"get_timestamp" $ nth date 1 |parse-time $ quote defn parse-time (time format) - :: Date $ &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"parse_time" time format + %:: Date :date $ &call-dylib-edn (get-dylib-path "\"/dylibs/libcalcit_std") "\"parse_time" time format :ns $ quote ns calcit.std.date $ :require calcit.std.$meta :refer $ calcit-dirname @@ -203,7 +203,7 @@ println $ get-time! echo |time: $ format-time (get-time!) "|%Y-%m-%d %H:%M:%S %z" assert= 1417176009000 $ get-timestamp (parse-time "|2014-11-28 21:00:09 +09:00" "|%Y-%m-%d %H:%M:%S %z") - ; assert= "|2014-11-28 12:00:09 +0000" $ format-time (:: Date 1417176009000) "|%Y-%m-%d %H:%M:%S %z" + ; assert= "|2014-11-28 12:00:09 +0000" $ format-time (%:: Date :date 1417176009000) "|%Y-%m-%d %H:%M:%S %z" w-log $ extract-time (get-time!) w-log $ from-ymd 2021 11 11 w-log $ from-ywd 2021 45 6 diff --git a/src/date.rs b/src/date.rs index 807a948..872bade 100644 --- a/src/date.rs +++ b/src/date.rs @@ -78,19 +78,19 @@ pub fn extract_time(args: Vec) -> Result { }; let mut data: HashMap = HashMap::new(); - data.insert(Edn::kwd("year"), Edn::Number(time.date_naive().year() as f64)); - data.insert(Edn::kwd("month"), Edn::Number(time.date_naive().month() as f64)); - data.insert(Edn::kwd("month0"), Edn::Number(time.date_naive().month0() as f64)); - data.insert(Edn::kwd("day"), Edn::Number(time.date_naive().day() as f64)); - data.insert(Edn::kwd("hour"), Edn::Number(time.hour() as f64)); - data.insert(Edn::kwd("minute"), Edn::Number(time.minute() as f64)); - data.insert(Edn::kwd("second"), Edn::Number(time.second() as f64)); + data.insert(Edn::tag("year"), Edn::Number(time.date_naive().year() as f64)); + data.insert(Edn::tag("month"), Edn::Number(time.date_naive().month() as f64)); + data.insert(Edn::tag("month0"), Edn::Number(time.date_naive().month0() as f64)); + data.insert(Edn::tag("day"), Edn::Number(time.date_naive().day() as f64)); + data.insert(Edn::tag("hour"), Edn::Number(time.hour() as f64)); + data.insert(Edn::tag("minute"), Edn::Number(time.minute() as f64)); + data.insert(Edn::tag("second"), Edn::Number(time.second() as f64)); data.insert( - Edn::kwd("weekday"), + Edn::tag("weekday"), Edn::Number(time.date_naive().weekday().num_days_from_sunday() as f64), ); - data.insert(Edn::kwd("week"), Edn::Number(time.date_naive().iso_week().week() as f64)); - data.insert(Edn::kwd("week0"), Edn::Number(time.date_naive().iso_week().week0() as f64)); + data.insert(Edn::tag("week"), Edn::Number(time.date_naive().iso_week().week() as f64)); + data.insert(Edn::tag("week0"), Edn::Number(time.date_naive().iso_week().week0() as f64)); Ok(Edn::Map(data)) } @@ -114,10 +114,10 @@ pub fn from_ymd(args: Vec) -> Result { .and_hms_opt(0, 0, 0) .ok_or("from_ymd got none")?, ) { - LocalResult::None => Ok(Edn::List(vec![Edn::kwd("none")])), - LocalResult::Single(d) => Ok(Edn::List(vec![Edn::kwd("single"), Edn::Number(d.timestamp_millis() as f64)])), + LocalResult::None => Ok(Edn::List(vec![Edn::tag("none")])), + LocalResult::Single(d) => Ok(Edn::List(vec![Edn::tag("single"), Edn::Number(d.timestamp_millis() as f64)])), LocalResult::Ambiguous(d, d2) => Ok(Edn::List(vec![ - Edn::kwd("ambiguous"), + Edn::tag("ambiguous"), Edn::Number(d.timestamp_millis() as f64), Edn::Number(d2.timestamp_millis() as f64), ])), @@ -146,17 +146,17 @@ pub fn from_ywd(args: Vec) -> Result { 6 => Weekday::Sat, _ => { return Ok(Edn::List(vec![ - Edn::kwd("err"), + Edn::tag("err"), Edn::str(format!("invalid digit for weekday: {d}")), ])) } }; match NaiveDate::from_isoywd_opt(*y as i32, *w as u32, weekday) { Some(time) => match Local.from_local_datetime(&time.and_hms_opt(0, 0, 0).ok_or("hms got none")?) { - LocalResult::None => Ok(Edn::List(vec![Edn::kwd("none")])), - LocalResult::Single(d) => Ok(Edn::List(vec![Edn::kwd("single"), Edn::Number(d.timestamp_millis() as f64)])), + LocalResult::None => Ok(Edn::List(vec![Edn::tag("none")])), + LocalResult::Single(d) => Ok(Edn::List(vec![Edn::tag("single"), Edn::Number(d.timestamp_millis() as f64)])), LocalResult::Ambiguous(d, d2) => Ok(Edn::List(vec![ - Edn::kwd("single"), + Edn::tag("single"), Edn::Number(d.timestamp_millis() as f64), Edn::Number(d2.timestamp_millis() as f64), ])), @@ -175,7 +175,7 @@ pub fn from_ywd(args: Vec) -> Result { pub fn add_duration(args: Vec) -> Result { if args.len() == 3 { match (&args[0], &args[1], &args[2]) { - (Edn::Number(d), Edn::Number(n), Edn::Keyword(k)) => { + (Edn::Number(d), Edn::Number(n), Edn::Tag(k)) => { let time = match Local.timestamp_opt((d.floor() / 1000.0) as i64, (d.fract() * 1_000_000.0) as u32) { LocalResult::Single(d) => d, LocalResult::None => return Err(format!("add-duration out of range: {d}")), diff --git a/src/json.rs b/src/json.rs index 08394ed..3dd9b69 100644 --- a/src/json.rs +++ b/src/json.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use serde_json::Value; -use cirru_edn::{Edn, EdnKwd}; +use cirru_edn::{Edn, EdnTag}; pub fn json_to_edn(data: &Value) -> Edn { match data { @@ -12,7 +12,7 @@ pub fn json_to_edn(data: &Value) -> Edn { Value::String(s) => { if s.starts_with(':') { // special logic to parse keyword - Edn::Keyword(EdnKwd::new(s.strip_prefix(':').unwrap())) + Edn::Tag(EdnTag::new(s.strip_prefix(':').unwrap())) } else { Edn::Str(s.to_owned().into_boxed_str()) } @@ -28,7 +28,7 @@ pub fn json_to_edn(data: &Value) -> Edn { let mut ys: HashMap = HashMap::new(); for (k, v) in xs { let key = if k.starts_with(':') { - Edn::kwd(k.strip_prefix(':').unwrap()) + Edn::tag(k.strip_prefix(':').unwrap()) } else { Edn::Str(k.to_owned().into_boxed_str()) }; @@ -49,7 +49,7 @@ pub fn edn_to_json(data: Edn, add_colon: bool) -> Result { None => Err(format!("failed to convert to number: {n}")), }, Edn::Symbol(s, ..) => Ok(Value::String((*s).to_string())), - Edn::Keyword(s) => { + Edn::Tag(s) => { if add_colon { Ok(Value::String(format!(":{s}"))) } else { @@ -71,7 +71,7 @@ pub fn edn_to_json(data: Edn, add_colon: bool) -> Result { Edn::Str(s) => { data.insert(s.to_string(), edn_to_json(v, add_colon)?); } - Edn::Keyword(s) => { + Edn::Tag(s) => { if add_colon { data.insert(format!(":{}", s.to_owned()), edn_to_json(v, add_colon)?); } else { From 5b0c988a0637f0380c78bb89e9aa91fccc5613ca Mon Sep 17 00:00:00 2001 From: tiye Date: Mon, 29 May 2023 01:09:21 +0800 Subject: [PATCH 2/2] disable nightly in CI script --- .github/workflows/check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 12bb2ae..c4765dd 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -16,7 +16,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly + # toolchain: nightly components: clippy - uses: supplypike/setup-bin@v3