From 81143f0b9c974bac57130c8cdd568975008e77cf Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sat, 18 Jan 2025 22:38:10 -0500 Subject: [PATCH] Fix a lot of very simple, easy warnings --- Cargo.lock | 9 - Cargo.toml | 1 - bike-lights/core/src/lib.rs | 79 +- bike-lights/simulator/src/main.rs | 12 + config/src/lib.rs | 6 + coordinates/src/hex.rs | 6 +- cyber-slides/src/main.rs | 36 +- cyberpunk-splash/src/main.rs | 2 +- cyberpunk/src/lib.rs | 4 +- dashboard/src/soluna_client.rs | 2 +- emseries/Cargo.toml | 1 + emseries/src/criteria.rs | 2 +- emseries/src/series.rs | 8 +- fitnesstrax/app/src/components/date_field.rs | 2 +- fitnesstrax/app/src/types.rs | 4 +- fitnesstrax/app/src/view_models/day_detail.rs | 4 +- fitnesstrax/app/src/views/historical_view.rs | 2 +- fitnesstrax/core/src/bin/legacy-importer.rs | 4 +- fluent-ergonomics/src/lib.rs | 12 +- gm-control-panel/src/app_window.rs | 6 +- gm-dash/server/src/main.rs | 4 +- hex-grid/src/main.rs | 2 - ifc/Cargo.lock | 400 ------- ifc/Cargo.toml | 14 - ifc/readme.md | 8 - ifc/src/lib.rs | 1042 ----------------- ifc/src/static/index.html | 34 - ifc/src/static/month.html | 35 - ifc/src/static/out_of_time.html | 12 - ifc/src/static/styles.css | 18 - ifc/src/today.rs | 22 - ifc/src/web.rs | 119 -- memorycache/src/lib.rs | 4 +- nom-training/src/lib.rs | 6 +- otg/core/src/goban.rs | 31 +- otg/core/src/types.rs | 6 +- otg/core/src/view_models/game_review.rs | 6 +- otg/gtk/src/app_window.rs | 2 +- otg/gtk/src/views/game_review.rs | 10 +- screenplay/src/lib.rs | 1 - timezone-testing/src/lib.rs | 8 +- tree/src/lib.rs | 6 + visions/server/src/asset_db.rs | 4 +- visions/server/src/core.rs | 4 +- visions/server/src/database/mod.rs | 4 +- .../server/src/handlers/game_management.rs | 5 +- visions/server/src/handlers/mod.rs | 7 +- .../server/src/handlers/user_management.rs | 2 +- 48 files changed, 144 insertions(+), 1874 deletions(-) delete mode 100644 ifc/Cargo.lock delete mode 100644 ifc/Cargo.toml delete mode 100644 ifc/readme.md delete mode 100644 ifc/src/lib.rs delete mode 100644 ifc/src/static/index.html delete mode 100644 ifc/src/static/month.html delete mode 100644 ifc/src/static/out_of_time.html delete mode 100644 ifc/src/static/styles.css delete mode 100644 ifc/src/today.rs delete mode 100644 ifc/src/web.rs diff --git a/Cargo.lock b/Cargo.lock index 375dd58..8d0fc71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2187,15 +2187,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "ifc" -version = "0.1.0" -dependencies = [ - "chrono", - "serde 1.0.210", - "thiserror 1.0.64", -] - [[package]] name = "image" version = "0.24.9" diff --git a/Cargo.toml b/Cargo.toml index 3424f9d..b9a0098 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ members = [ "gm-control-panel", "hex-grid", "icon-test", - "ifc", "memorycache", "nom-training", "otg/core", diff --git a/bike-lights/core/src/lib.rs b/bike-lights/core/src/lib.rs index 824f1ca..61d0a33 100644 --- a/bike-lights/core/src/lib.rs +++ b/bike-lights/core/src/lib.rs @@ -38,7 +38,7 @@ pub struct Instant(pub U128F0); impl Default for Instant { fn default() -> Self { - Self(U128F0::from(0 as u8)) + Self(U128F0::from(0_u8)) } } @@ -198,7 +198,7 @@ impl Blinker { direction: BlinkerDirection, time: Instant, ) -> Self { - let mut ending_dashboard = OFF_DASHBOARD.clone(); + let mut ending_dashboard = OFF_DASHBOARD; match direction { BlinkerDirection::Left => { @@ -213,7 +213,7 @@ impl Blinker { } } - let mut ending_body = OFF_BODY.clone(); + let mut ending_body = OFF_BODY; match direction { BlinkerDirection::Left => { for i in 0..30 { @@ -233,26 +233,26 @@ impl Blinker { Blinker { transition: Fade::new( - starting_dashboard.clone(), - starting_body.clone(), - ending_dashboard.clone(), - ending_body.clone(), + starting_dashboard, + starting_body, + ending_dashboard, + ending_body, BLINKER_FRAMES, time, ), fade_in: Fade::new( - OFF_DASHBOARD.clone(), - OFF_BODY.clone(), - ending_dashboard.clone(), - ending_body.clone(), + OFF_DASHBOARD, + OFF_BODY, + ending_dashboard, + ending_body, BLINKER_FRAMES, time, ), fade_out: Fade::new( - ending_dashboard.clone(), - ending_body.clone(), - OFF_DASHBOARD.clone(), - OFF_BODY.clone(), + ending_dashboard, + ending_body, + OFF_DASHBOARD, + OFF_BODY, BLINKER_FRAMES, time, ), @@ -375,7 +375,7 @@ impl App { pattern.dashboard(), pattern.body(), DEFAULT_FRAMES, - Instant((0 as u32).into()), + Instant(0_u32.into()), )), dashboard_lights: OFF_DASHBOARD, lights: OFF_BODY, @@ -386,8 +386,8 @@ impl App { match self.state { State::Pattern(ref pattern) => { self.current_animation = Box::new(Fade::new( - self.dashboard_lights.clone(), - self.lights.clone(), + self.dashboard_lights, + self.lights, pattern.dashboard(), pattern.body(), DEFAULT_FRAMES, @@ -396,8 +396,8 @@ impl App { } State::Brake => { self.current_animation = Box::new(Fade::new( - self.dashboard_lights.clone(), - self.lights.clone(), + self.dashboard_lights, + self.lights, BRAKES_DASHBOARD, BRAKES_BODY, BRAKES_FRAMES, @@ -406,16 +406,16 @@ impl App { } State::LeftBlinker => { self.current_animation = Box::new(Blinker::new( - self.dashboard_lights.clone(), - self.lights.clone(), + self.dashboard_lights, + self.lights, BlinkerDirection::Left, time, )); } State::RightBlinker => { self.current_animation = Box::new(Blinker::new( - self.dashboard_lights.clone(), - self.lights.clone(), + self.dashboard_lights, + self.lights, BlinkerDirection::Right, time, )); @@ -441,19 +441,13 @@ impl App { State::LeftBlinker => self.state = State::Pattern(self.home_pattern), _ => self.state = State::LeftBlinker, }, - Event::NextPattern => match self.state { - State::Pattern(ref pattern) => { - self.home_pattern = pattern.next(); - self.state = State::Pattern(self.home_pattern); - } - _ => (), + Event::NextPattern => if let State::Pattern(ref pattern) = self.state { + self.home_pattern = pattern.next(); + self.state = State::Pattern(self.home_pattern); }, - Event::PreviousPattern => match self.state { - State::Pattern(ref pattern) => { - self.home_pattern = pattern.previous(); - self.state = State::Pattern(self.home_pattern); - } - _ => (), + Event::PreviousPattern => if let State::Pattern(ref pattern) = self.state { + self.home_pattern = pattern.previous(); + self.state = State::Pattern(self.home_pattern); }, Event::RightBlinker => match self.state { State::Brake => self.state = State::BrakeRightBlinker, @@ -465,17 +459,14 @@ impl App { } pub fn tick(&mut self, time: Instant) { - match self.ui.check_event(time) { - Some(event) => { - self.update_state(event); - self.update_animation(time); - } - None => {} + if let Some(event) = self.ui.check_event(time) { + self.update_state(event); + self.update_animation(time); }; let (dashboard, lights) = self.current_animation.tick(time); - self.dashboard_lights = dashboard.clone(); - self.lights = lights.clone(); + self.dashboard_lights = dashboard; + self.lights = lights; self.ui.update_lights(dashboard, lights); } } diff --git a/bike-lights/simulator/src/main.rs b/bike-lights/simulator/src/main.rs index e96d0ee..a1da0ac 100644 --- a/bike-lights/simulator/src/main.rs +++ b/bike-lights/simulator/src/main.rs @@ -45,6 +45,12 @@ glib::wrapper! { pub struct DashboardLights(ObjectSubclass) @extends gtk::DrawingArea, gtk::Widget; } +impl Default for DashboardLights { + fn default() -> Self { + Self::new() + } +} + impl DashboardLights { pub fn new() -> Self { let s: Self = Object::builder().build(); @@ -103,6 +109,12 @@ glib::wrapper! { pub struct BikeLights(ObjectSubclass) @extends gtk::DrawingArea, gtk::Widget; } +impl Default for BikeLights { + fn default() -> Self { + Self::new() + } +} + impl BikeLights { pub fn new() -> Self { let s: Self = Object::builder().build(); diff --git a/config/src/lib.rs b/config/src/lib.rs index 4a24421..28dba76 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -40,6 +40,12 @@ macro_rules! define_config { values: std::collections::HashMap, } + impl Default for Config { + fn default() -> Self { + Self::new() + } + } + impl Config { pub fn new() -> Self { Self { diff --git a/coordinates/src/hex.rs b/coordinates/src/hex.rs index d11b3a7..50e8631 100644 --- a/coordinates/src/hex.rs +++ b/coordinates/src/hex.rs @@ -145,7 +145,7 @@ mod tests { let coord2 = &lst1[idx]; assert!(coord2.is_adjacent(&coord1)); - assert!(coord1.is_adjacent(&coord2)); + assert!(coord1.is_adjacent(coord2)); } #[test] @@ -166,10 +166,10 @@ mod tests { let hexaddr = AxialAddr::new(q, r); let en_distancaj_hexaddr: Vec = hexaddr.addresses(distance).collect(); - let expected_cnt = ((0..distance+1).map(|v| v * 6).fold(1, |acc, val| acc + val)) as usize; + let expected_cnt = (0..distance+1).map(|v| v * 6).fold(1, |acc, val| acc + val); assert_eq!(en_distancaj_hexaddr.len(), expected_cnt); for c in en_distancaj_hexaddr { - assert!(c.distance(&hexaddr) <= distance as usize); + assert!(c.distance(&hexaddr) <= distance); } } } diff --git a/cyber-slides/src/main.rs b/cyber-slides/src/main.rs index c0c62b3..7d09dfc 100644 --- a/cyber-slides/src/main.rs +++ b/cyber-slides/src/main.rs @@ -12,9 +12,9 @@ use std::{ use cairo::{Context, Rectangle}; use cyberpunk::{AsymLine, AsymLineCutout, GlowPen, Pen, Text}; -use glib::{GString, Object}; +use glib::Object; use gtk::{ - glib::{self, Propagation}, + glib::{self}, prelude::*, subclass::prelude::*, EventControllerKey, @@ -40,6 +40,7 @@ struct Step { } #[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Default)] struct Script(Vec); impl Script { @@ -51,7 +52,7 @@ impl Script { Ok(Self(script)) } - fn iter<'a>(&'a self) -> impl Iterator { + fn iter(&self) -> impl Iterator { self.0.iter() } @@ -60,11 +61,6 @@ impl Script { } } -impl Default for Script { - fn default() -> Self { - Self(vec![]) - } -} impl Index for Script { type Output = Step; @@ -98,11 +94,11 @@ impl Animation for Fade { let alpha_rate: f64 = 1. / total_frames as f64; let frames = (now - self.start_time).as_secs_f64() * FPS as f64; - let alpha = alpha_rate * frames as f64; + let alpha = alpha_rate * frames; let text_display = Text::new(self.text.clone(), context, 64., width); - let _ = context.move_to(0., text_display.extents().height()); - let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha); + context.move_to(0., text_display.extents().height()); + context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha); text_display.draw(); } } @@ -126,16 +122,16 @@ impl Animation for CrossFade { let alpha_rate: f64 = 1. / total_frames as f64; let frames = (now - self.start_time).as_secs_f64() * FPS as f64; - let alpha = alpha_rate * frames as f64; + let alpha = alpha_rate * frames; let text_display = Text::new(self.old_text.clone(), context, 64., width); - let _ = context.move_to(0., text_display.extents().height()); - let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, 1. - alpha); + context.move_to(0., text_display.extents().height()); + context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, 1. - alpha); text_display.draw(); let text_display = Text::new(self.new_text.clone(), context, 64., width); - let _ = context.move_to(0., text_display.extents().height()); - let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha); + context.move_to(0., text_display.extents().height()); + context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha); text_display.draw(); } } @@ -163,9 +159,7 @@ impl Default for CyberScreenState { impl CyberScreenState { fn new(script: Script) -> CyberScreenState { - let mut s = CyberScreenState::default(); - s.script = script; - s + CyberScreenState { script, ..Default::default() } } fn next_page(&mut self) -> Box { @@ -260,7 +254,7 @@ impl CyberScreen { let s = s.clone(); move |_, context, width, height| { let now = Instant::now(); - let _ = context.set_source_rgb(0., 0., 0.); + context.set_source_rgb(0., 0., 0.); let _ = context.paint(); let pen = GlowPen::new(width, height, 2., 8., (0.7, 0., 1.)); @@ -293,7 +287,7 @@ impl CyberScreen { let _ = context.set_source(tracery); let _ = context.paint(); - let mut animations = s.imp().animations.borrow_mut(); + let animations = s.imp().animations.borrow_mut(); let lr_margin = 50.; let max_width = width as f64 - lr_margin * 2.; diff --git a/cyberpunk-splash/src/main.rs b/cyberpunk-splash/src/main.rs index 0a7214c..aae1235 100644 --- a/cyberpunk-splash/src/main.rs +++ b/cyberpunk-splash/src/main.rs @@ -1,5 +1,5 @@ use cairo::{ - Context, FontSlant, FontWeight, Format, ImageSurface, LineCap, LinearGradient, Pattern, + Context, FontSlant, FontWeight, Format, ImageSurface, LinearGradient, Pattern, TextExtents, }; use cyberpunk::{AsymLine, AsymLineCutout, GlowPen, Pen, SlashMeter}; diff --git a/cyberpunk/src/lib.rs b/cyberpunk/src/lib.rs index 6697e49..29317b5 100644 --- a/cyberpunk/src/lib.rs +++ b/cyberpunk/src/lib.rs @@ -274,7 +274,7 @@ impl<'a> Text<'a> { for line in self.content.iter() { baseline += self.context.text_extents(line).unwrap().height() + 10.; self.context.move_to(0., baseline); - let _ = self.context.show_text(&line); + let _ = self.context.show_text(line); } } } @@ -294,7 +294,7 @@ fn word_wrap(content: String, context: &Context, max_width: f64) -> Vec lines.push(line.clone()); } } - if line.len() > 0 { + if !line.is_empty() { lines.push(line); } lines diff --git a/dashboard/src/soluna_client.rs b/dashboard/src/soluna_client.rs index d783311..21c89d5 100644 --- a/dashboard/src/soluna_client.rs +++ b/dashboard/src/soluna_client.rs @@ -132,7 +132,7 @@ impl SolunaClient { #[cfg(test)] mod test { use super::*; - use serde_json; + const EXAMPLE: &str = "{\"sunRise\":\"7:15\",\"sunTransit\":\"12:30\",\"sunSet\":\"17:45\",\"moonRise\":null,\"moonTransit\":\"7:30\",\"moonUnder\":\"19:54\",\"moonSet\":\"15:02\",\"moonPhase\":\"Waning Crescent\",\"moonIllumination\":0.35889454647387764,\"sunRiseDec\":7.25,\"sunTransitDec\":12.5,\"sunSetDec\":17.75,\"moonRiseDec\":null,\"moonSetDec\":15.033333333333333,\"moonTransitDec\":7.5,\"moonUnderDec\":19.9,\"minor1Start\":null,\"minor1Stop\":null,\"minor2StartDec\":14.533333333333333,\"minor2Start\":\"14:32\",\"minor2StopDec\":15.533333333333333,\"minor2Stop\":\"15:32\",\"major1StartDec\":6.5,\"major1Start\":\"06:30\",\"major1StopDec\":8.5,\"major1Stop\":\"08:30\",\"major2StartDec\":18.9,\"major2Start\":\"18:54\",\"major2StopDec\":20.9,\"major2Stop\":\"20:54\",\"dayRating\":1,\"hourlyRating\":{\"0\":20,\"1\":20,\"2\":0,\"3\":0,\"4\":0,\"5\":0,\"6\":20,\"7\":40,\"8\":40,\"9\":20,\"10\":0,\"11\":0,\"12\":0,\"13\":0,\"14\":0,\"15\":20,\"16\":20,\"17\":20,\"18\":40,\"19\":20,\"20\":20,\"21\":20,\"22\":0,\"23\":0}}"; diff --git a/emseries/Cargo.toml b/emseries/Cargo.toml index b92e660..dee39d2 100644 --- a/emseries/Cargo.toml +++ b/emseries/Cargo.toml @@ -9,6 +9,7 @@ documentation = "https://docs.rs/emseries" homepage = "https://github.com/luminescent-dreams/emseries" repository = "https://github.com/luminescent-dreams/emseries" categories = ["database-implementations"] +edition = "2021" include = [ "**/*.rs", diff --git a/emseries/src/criteria.rs b/emseries/src/criteria.rs index 9f304e6..ea0059e 100644 --- a/emseries/src/criteria.rs +++ b/emseries/src/criteria.rs @@ -10,7 +10,7 @@ Luminescent Dreams Tools is distributed in the hope that it will be useful, but You should have received a copy of the GNU General Public License along with Lumeto. If not, see . */ -use types::{Recordable, Timestamp}; +use crate::types::{Recordable, Timestamp}; /// This trait is used for constructing queries for searching the database. pub trait Criteria { diff --git a/emseries/src/series.rs b/emseries/src/series.rs index 0e6441b..1d3dc42 100644 --- a/emseries/src/series.rs +++ b/emseries/src/series.rs @@ -10,10 +10,6 @@ Luminescent Dreams Tools is distributed in the hope that it will be useful, but You should have received a copy of the GNU General Public License along with Lumeto. If not, see . */ -extern crate serde; -extern crate serde_json; -extern crate uuid; - use serde::de::DeserializeOwned; use serde::ser::Serialize; use std::cmp::Ordering; @@ -24,8 +20,8 @@ use std::fs::OpenOptions; use std::io::{BufRead, BufReader, LineWriter, Write}; use std::iter::Iterator; -use criteria::Criteria; -use types::{EmseriesReadError, EmseriesWriteError, Record, RecordId, Recordable}; +use crate::criteria::Criteria; +use crate::types::{EmseriesReadError, EmseriesWriteError, Record, RecordId, Recordable}; // A RecordOnDisk, a private data structure, is useful for handling all of the on-disk // representations of a record. Unlike [Record], this one can accept an empty data value to diff --git a/fitnesstrax/app/src/components/date_field.rs b/fitnesstrax/app/src/components/date_field.rs index fc6a80a..a01d13d 100644 --- a/fitnesstrax/app/src/components/date_field.rs +++ b/fitnesstrax/app/src/components/date_field.rs @@ -153,7 +153,7 @@ mod test { #[test] #[ignore] fn it_allows_valid_dates() { - let reference = chrono::NaiveDate::from_ymd_opt(2006, 01, 02).unwrap(); + let reference = chrono::NaiveDate::from_ymd_opt(2006, 1, 2).unwrap(); let field = DateField::new(reference); field.imp().year.set_value(Some(2023)); field.imp().month.set_value(Some(10)); diff --git a/fitnesstrax/app/src/types.rs b/fitnesstrax/app/src/types.rs index 36a7252..8711d7c 100644 --- a/fitnesstrax/app/src/types.rs +++ b/fitnesstrax/app/src/types.rs @@ -80,10 +80,10 @@ impl TimeFormatter { 0 => Err(ParseError), 1 => Err(ParseError), 2 => chrono::NaiveTime::from_hms_opt(parts[0], parts[1], 0) - .map(|v| TimeFormatter(v)) + .map(TimeFormatter) .ok_or(ParseError), 3 => chrono::NaiveTime::from_hms_opt(parts[0], parts[1], parts[2]) - .map(|v| TimeFormatter(v)) + .map(TimeFormatter) .ok_or(ParseError), _ => Err(ParseError), } diff --git a/fitnesstrax/app/src/view_models/day_detail.rs b/fitnesstrax/app/src/view_models/day_detail.rs index ab379d2..63e4c9b 100644 --- a/fitnesstrax/app/src/view_models/day_detail.rs +++ b/fitnesstrax/app/src/view_models/day_detail.rs @@ -443,7 +443,7 @@ mod test { async fn put_record(&self, record: TraxRecord) -> Result { let id = RecordId::default(); let record = Record { - id: id, + id, data: record, }; self.put_records.write().unwrap().push(record.clone()); @@ -509,7 +509,7 @@ mod test { Record { id: RecordId::default(), data: TraxRecord::TimeDistance(ft_core::TimeDistance { - datetime: oct_13_am.clone(), + datetime: oct_13_am, activity: TimeDistanceActivity::Biking, distance: Some(15000. * si::M), duration: Some(3600. * si::S), diff --git a/fitnesstrax/app/src/views/historical_view.rs b/fitnesstrax/app/src/views/historical_view.rs index 8357c74..7ae9a59 100644 --- a/fitnesstrax/app/src/views/historical_view.rs +++ b/fitnesstrax/app/src/views/historical_view.rs @@ -144,7 +144,7 @@ impl HistoricalView { let mut model = gio::ListStore::new::(); let mut days = interval.days().map(Date::new).collect::>(); days.reverse(); - model.extend(days.into_iter()); + model.extend(days); self.imp() .list_view .set_model(Some(>k::NoSelection::new(Some(model)))); diff --git a/fitnesstrax/core/src/bin/legacy-importer.rs b/fitnesstrax/core/src/bin/legacy-importer.rs index 77b6423..e080b8d 100644 --- a/fitnesstrax/core/src/bin/legacy-importer.rs +++ b/fitnesstrax/core/src/bin/legacy-importer.rs @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Fit use chrono::SecondsFormat; use chrono_tz::Etc::UTC; use dimensioned::si; -use emseries::{Record, RecordId, Series, Timestamp}; +use emseries::{Record, RecordId}; use ft_core::{self, DurationWorkout, DurationWorkoutActivity, SetRepActivity, TraxRecord}; use serde::{ de::{self, Visitor}, @@ -26,7 +26,7 @@ use serde::{ use std::{ fmt, fs::File, - io::{BufRead, BufReader, Read}, + io::{BufRead, BufReader}, str::FromStr, }; diff --git a/fluent-ergonomics/src/lib.rs b/fluent-ergonomics/src/lib.rs index 06feb80..6410be0 100644 --- a/fluent-ergonomics/src/lib.rs +++ b/fluent-ergonomics/src/lib.rs @@ -294,21 +294,21 @@ mod tests { use fluent_bundle::{FluentArgs, FluentValue}; use unic_langid::LanguageIdentifier; - const EN_TRANSLATIONS: &'static str = " + const EN_TRANSLATIONS: &str = " preferences = Preferences history = History time_display = {$time} during the day nested_display = nesting a time display: {time_display} "; - const EO_TRANSLATIONS: &'static str = " + const EO_TRANSLATIONS: &str = " history = Historio "; #[test] fn translations() { let en_id = "en-US".parse::().unwrap(); - let mut fluent = FluentErgo::new(&vec![en_id.clone()]); + let mut fluent = FluentErgo::new(&[en_id.clone()]); fluent .add_from_text(en_id, String::from(EN_TRANSLATIONS)) .expect("text should load"); @@ -322,7 +322,7 @@ history = Historio fn translation_fallback() { let eo_id = "eo".parse::().unwrap(); let en_id = "en".parse::().unwrap(); - let mut fluent = FluentErgo::new(&vec![eo_id.clone(), en_id.clone()]); + let mut fluent = FluentErgo::new(&[eo_id.clone(), en_id.clone()]); fluent .add_from_text(en_id, String::from(EN_TRANSLATIONS)) .expect("text should load"); @@ -342,7 +342,7 @@ history = Historio #[test] fn placeholder_insertion_should_strip_placeholder_markers() { let en_id = "en".parse::().unwrap(); - let mut fluent = FluentErgo::new(&vec![en_id.clone()]); + let mut fluent = FluentErgo::new(&[en_id.clone()]); fluent .add_from_text(en_id, String::from(EN_TRANSLATIONS)) .expect("text should load"); @@ -357,7 +357,7 @@ history = Historio #[test] fn placeholder_insertion_should_strip_nested_placeholder_markers() { let en_id = "en".parse::().unwrap(); - let mut fluent = FluentErgo::new(&vec![en_id.clone()]); + let mut fluent = FluentErgo::new(&[en_id.clone()]); fluent .add_from_text(en_id, String::from(EN_TRANSLATIONS)) .expect("text should load"); diff --git a/gm-control-panel/src/app_window.rs b/gm-control-panel/src/app_window.rs index 360c289..d4c25b2 100644 --- a/gm-control-panel/src/app_window.rs +++ b/gm-control-panel/src/app_window.rs @@ -7,8 +7,8 @@ use std::iter::Iterator; #[derive(Clone)] pub struct ApplicationWindow { pub window: adw::ApplicationWindow, - pub layout: gtk::FlowBox, - pub playlists: Vec, + // pub layout: gtk::FlowBox, + // pub playlists: Vec, } impl ApplicationWindow { @@ -57,8 +57,10 @@ impl ApplicationWindow { Self { window, + /* layout, playlists, + */ } } } diff --git a/gm-dash/server/src/main.rs b/gm-dash/server/src/main.rs index c80aec8..7d7beaa 100644 --- a/gm-dash/server/src/main.rs +++ b/gm-dash/server/src/main.rs @@ -27,12 +27,12 @@ impl State { fn add_audio(&self, device: String) { let mut st = self.internal.write().unwrap(); - (*st).device_list.push(device); + st.device_list.push(device); } fn audio_devices(&self) -> Vec { let st = self.internal.read().unwrap(); - (*st).device_list.clone() + st.device_list.clone() } } diff --git a/hex-grid/src/main.rs b/hex-grid/src/main.rs index 509c23c..7778d48 100644 --- a/hex-grid/src/main.rs +++ b/hex-grid/src/main.rs @@ -107,8 +107,6 @@ impl ObjectSubclass for HexGridWindowPrivate { layout.append(&drawing_area); layout.append(&sidebar); - layout.show(); - Self { drawing_area, hex_address, diff --git a/ifc/Cargo.lock b/ifc/Cargo.lock deleted file mode 100644 index 188b9d6..0000000 --- a/ifc/Cargo.lock +++ /dev/null @@ -1,400 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bumpalo" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" - -[[package]] -name = "cc" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "time", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "cxx" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "international-fixed-calendar" -version = "0.1.0" -dependencies = [ - "chrono", - "serde", - "thiserror", -] - -[[package]] -name = "js-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" - -[[package]] -name = "proc-macro2" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "scratch" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "syn" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi", - "winapi", -] - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/ifc/Cargo.toml b/ifc/Cargo.toml deleted file mode 100644 index 30cd94d..0000000 --- a/ifc/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "ifc" -description = "chrono-compatible-ish date objects for the International Fixed Calendar" -version = "0.1.0" -authors = ["Savanni D'Gerinel "] -edition = "2018" -keywords = ["date", "time", "calendar"] -categories = ["date-and-time"] -license = "GPL-3.0-only" - -[dependencies] -chrono = { version = "0.4" } -serde = { version = "1.0", features = ["derive"] } -thiserror = { version = "1" } diff --git a/ifc/readme.md b/ifc/readme.md deleted file mode 100644 index 6502e17..0000000 --- a/ifc/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -# International Fixed Calendar - -This is a fun project implementing a library for the [International Fixed Calendar](https://en.wikipedia.org/wiki/International_Fixed_Calendar). - -This is at least somewhat compatible with [Chrono](https://github.com/chronotope/chrono), in that I have implemented these traits: - -* `From` -* `Datelike` diff --git a/ifc/src/lib.rs b/ifc/src/lib.rs deleted file mode 100644 index 83b5719..0000000 --- a/ifc/src/lib.rs +++ /dev/null @@ -1,1042 +0,0 @@ -/* -Copyright 2020-2023, Savanni D'Gerinel - -This file is part of the Luminescent Dreams Tools. - -Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with Lumeto. If not, see . -*/ - -use chrono::{Datelike, NaiveDate}; -use serde::{Deserialize, Serialize}; -use std::convert::TryInto; -use thiserror::Error; - -#[derive(Clone, Debug, Error, PartialEq)] -pub enum Error { - #[error("invalid date")] - InvalidDate, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum DayOfWeek { - Sunday, - Monday, - Tuesday, - Wednesday, - Thursday, - Friday, - Saturday, - LeapDay, - YearDay, -} - -impl From for String { - fn from(day: DayOfWeek) -> Self { - match day { - DayOfWeek::Sunday => "Sunday", - DayOfWeek::Monday => "Monday", - DayOfWeek::Tuesday => "Tuesday", - DayOfWeek::Wednesday => "Wednesday", - DayOfWeek::Thursday => "Thursday", - DayOfWeek::Friday => "Friday", - DayOfWeek::Saturday => "Saturday", - DayOfWeek::LeapDay => "LeapDay", - DayOfWeek::YearDay => "YearDay", - } - .to_owned() - } -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum Month { - January, - February, - March, - April, - May, - June, - Sol, - July, - August, - September, - October, - November, - December, -} - -impl From for Month { - fn from(val: u32) -> Month { - match val { - 1 => Month::January, - 2 => Month::February, - 3 => Month::March, - 4 => Month::April, - 5 => Month::May, - 6 => Month::June, - 7 => Month::Sol, - 8 => Month::July, - 9 => Month::August, - 10 => Month::September, - 11 => Month::October, - 12 => Month::November, - 13 => Month::December, - _ => panic!("invalid month number"), - } - } -} - -impl From for Month { - fn from(val: u8) -> Month { - Month::from(val as u32) - } -} - -impl From for String { - fn from(val: Month) -> String { - match val { - Month::January => "January", - Month::February => "February", - Month::March => "March", - Month::April => "April", - Month::May => "May", - Month::June => "June", - Month::Sol => "Sol", - Month::July => "July", - Month::August => "August", - Month::September => "September", - Month::October => "October", - Month::November => "November", - Month::December => "December", - } - .to_owned() - } -} - -fn is_leap_year(year: i32) -> bool { - NaiveDate::from_ymd_opt(year, 12, 31).unwrap().ordinal() == 366 -} - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum IFC { - LeapDay(i32), - YearDay(i32), - Day(Day), -} - -impl IFC { - pub fn leap_day(year: i32) -> Result { - if is_leap_year(year) { - Ok(Self::LeapDay(year)) - } else { - Err(Error::InvalidDate) - } - } - - pub fn year_day(year: i32) -> Self { - Self::YearDay(year) - } - - pub fn ymd(year: i32, month: u8, day: u8) -> Result { - if !(1..=13).contains(&month) || !(1..=28).contains(&day) { - Err(Error::InvalidDate) - } else { - Ok(Self::Day(Day { year, month, day })) - } - } - - pub fn year(&self) -> i32 { - match *self { - IFC::LeapDay(year) => year, - IFC::YearDay(year) => year, - IFC::Day(Day { year, .. }) => year, - } - } - - pub fn month(&self) -> Month { - match *self { - IFC::Day(Day { month, .. }) => Month::from(month), - IFC::LeapDay(_) => Month::June, - IFC::YearDay(_) => Month::December, - } - } - - pub fn day(&self) -> u8 { - match *self { - IFC::Day(Day { day, .. }) => day, - IFC::LeapDay(_) => 29, - IFC::YearDay(_) => 29, - } - } - - pub fn weekday(&self) -> DayOfWeek { - match *self { - IFC::LeapDay(_) => DayOfWeek::LeapDay, - IFC::YearDay(_) => DayOfWeek::YearDay, - IFC::Day(Day { day, .. }) => match (day - 1) % 7 { - 0 => DayOfWeek::Sunday, - 1 => DayOfWeek::Monday, - 2 => DayOfWeek::Tuesday, - 3 => DayOfWeek::Wednesday, - 4 => DayOfWeek::Thursday, - 5 => DayOfWeek::Friday, - 6 => DayOfWeek::Saturday, - _ => panic!("impossible calculation"), - }, - } - } - - pub fn day_ordinal(&self) -> u32 { - self.day_ordinal0() + 1 - } - - pub fn day_ordinal0(&self) -> u32 { - match *self { - IFC::LeapDay(_) => 168, - IFC::YearDay(year) => { - if is_leap_year(year) { - 365 - } else { - 364 - } - } - IFC::Day(Day { year, month, day }) => { - u32::from(month - 1) * 28 - + u32::from(day - 1) - + if is_leap_year(year) && month > 6 { - 1 - } else { - 0 - } - } - } - } - - pub fn week_ordinal(&self) -> u32 { - self.week_ordinal0() + 1 - } - - pub fn week_ordinal0(&self) -> u32 { - match *self { - IFC::LeapDay(_) => 0, - IFC::YearDay(_) => 0, - IFC::Day(Day { month, day, .. }) => u32::from(month - 1) * 4 + (u32::from(day - 1) / 7), - } - } -} - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct Day { - pub year: i32, - pub month: u8, - pub day: u8, -} - -impl From for IFC { - fn from(date: chrono::NaiveDate) -> Self { - if date.month() == 12 && date.day() == 31 { - Self::YearDay(date.year()) - } else if is_leap_year(date.year()) && date.month() == 6 && date.day() == 17 { - Self::LeapDay(date.year()) - } else { - let mut days = date.ordinal(); - if is_leap_year(date.year()) - && date > NaiveDate::from_ymd_opt(date.year(), 6, 17).unwrap() - { - days -= 1; - } - let mut month: u8 = (days / 28).try_into().unwrap(); - let mut day: u8 = (days % 28).try_into().unwrap(); - if day == 0 { - month -= 1; - day = 28; - } - Self::Day(Day { - year: date.year(), - month: month + 1, - day, - }) - } - } -} - -impl From for chrono::NaiveDate { - fn from(ifc: IFC) -> Self { - Self::from_ymd_opt(ifc.year(), 1, 1).unwrap() - + chrono::naive::Days::new(ifc.day_ordinal0().into()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - use chrono::NaiveDate; - - #[test] - fn creates_a_day() { - assert_eq!(IFC::leap_day(12020), Ok(IFC::LeapDay(12020))); - assert_eq!(IFC::year_day(12020), IFC::YearDay(12020)); - assert_eq!( - IFC::ymd(12022, 13, 28), - Ok(IFC::Day(Day { - year: 12022, - month: 13, - day: 28 - })) - ); - } - - #[test] - fn rejects_invalid_dates() { - assert_eq!(IFC::leap_day(12022), Err(Error::InvalidDate)); - assert_eq!(IFC::ymd(12022, 13, 0), Err(Error::InvalidDate)); - assert_eq!(IFC::ymd(12022, 14, 1), Err(Error::InvalidDate)); - } - - #[test] - fn it_expresses_day_of_week() { - assert_eq!(IFC::leap_day(12020).unwrap().weekday(), DayOfWeek::LeapDay); - assert_eq!(IFC::year_day(12022).weekday(), DayOfWeek::YearDay); - assert_eq!(IFC::ymd(12022, 1, 1).unwrap().weekday(), DayOfWeek::Sunday); - assert_eq!(IFC::ymd(12022, 1, 2).unwrap().weekday(), DayOfWeek::Monday); - assert_eq!(IFC::ymd(12022, 1, 3).unwrap().weekday(), DayOfWeek::Tuesday); - assert_eq!( - IFC::ymd(12022, 1, 4).unwrap().weekday(), - DayOfWeek::Wednesday - ); - assert_eq!( - IFC::ymd(12022, 1, 5).unwrap().weekday(), - DayOfWeek::Thursday - ); - assert_eq!(IFC::ymd(12022, 1, 6).unwrap().weekday(), DayOfWeek::Friday); - assert_eq!( - IFC::ymd(12022, 1, 7).unwrap().weekday(), - DayOfWeek::Saturday - ); - assert_eq!(IFC::ymd(12022, 1, 8).unwrap().weekday(), DayOfWeek::Sunday); - } - - #[test] - fn it_expresses_month() { - assert_eq!(IFC::ymd(12022, 1, 4).unwrap().month(), Month::January); - assert_eq!(IFC::ymd(12022, 12, 1).unwrap().month(), Month::November); - assert_eq!(IFC::leap_day(12020).unwrap().month(), Month::June); - assert_eq!(IFC::year_day(12020).month(), Month::December); - } - - #[test] - fn it_reports_ordinal_days() { - assert_eq!(IFC::ymd(12022, 1, 1).unwrap().day_ordinal(), 1); - assert_eq!(IFC::ymd(12022, 1, 1).unwrap().day_ordinal0(), 0); - - assert_eq!(IFC::ymd(12022, 1, 28).unwrap().day_ordinal(), 28); - assert_eq!(IFC::ymd(12022, 1, 28).unwrap().day_ordinal0(), 27); - - assert_eq!(IFC::ymd(12022, 2, 1).unwrap().day_ordinal(), 29); - assert_eq!(IFC::ymd(12022, 2, 1).unwrap().day_ordinal0(), 28); - - assert_eq!(IFC::ymd(12022, 3, 1).unwrap().day_ordinal(), 57); - assert_eq!(IFC::ymd(12022, 3, 1).unwrap().day_ordinal0(), 56); - - assert_eq!(IFC::ymd(12022, 4, 1).unwrap().day_ordinal(), 85); - assert_eq!(IFC::ymd(12022, 4, 1).unwrap().day_ordinal0(), 84); - - assert_eq!(IFC::ymd(12022, 5, 1).unwrap().day_ordinal(), 113); - assert_eq!(IFC::ymd(12022, 5, 1).unwrap().day_ordinal0(), 112); - - assert_eq!(IFC::ymd(12022, 6, 1).unwrap().day_ordinal(), 141); - assert_eq!(IFC::ymd(12022, 6, 1).unwrap().day_ordinal0(), 140); - - assert_eq!(IFC::ymd(12022, 7, 1).unwrap().day_ordinal(), 169); - assert_eq!(IFC::ymd(12022, 7, 1).unwrap().day_ordinal0(), 168); - - assert_eq!(IFC::ymd(12022, 8, 1).unwrap().day_ordinal(), 197); - assert_eq!(IFC::ymd(12022, 8, 1).unwrap().day_ordinal0(), 196); - - assert_eq!(IFC::ymd(12022, 9, 1).unwrap().day_ordinal(), 225); - assert_eq!(IFC::ymd(12022, 9, 1).unwrap().day_ordinal0(), 224); - - assert_eq!(IFC::ymd(12022, 10, 1).unwrap().day_ordinal(), 253); - assert_eq!(IFC::ymd(12022, 10, 1).unwrap().day_ordinal0(), 252); - - assert_eq!(IFC::ymd(12022, 11, 1).unwrap().day_ordinal(), 281); - assert_eq!(IFC::ymd(12022, 11, 1).unwrap().day_ordinal0(), 280); - - assert_eq!(IFC::ymd(12022, 12, 1).unwrap().day_ordinal(), 309); - assert_eq!(IFC::ymd(12022, 12, 1).unwrap().day_ordinal0(), 308); - - assert_eq!(IFC::ymd(12022, 13, 1).unwrap().day_ordinal(), 337); - assert_eq!(IFC::ymd(12022, 13, 1).unwrap().day_ordinal0(), 336); - - assert_eq!(IFC::ymd(12022, 13, 28).unwrap().day_ordinal(), 364); - assert_eq!(IFC::ymd(12022, 13, 28).unwrap().day_ordinal0(), 363); - - assert_eq!(IFC::year_day(12022).day_ordinal(), 365); - } - - #[test] - fn it_reports_ordinal_days_on_leap_year() { - assert_eq!(IFC::ymd(12020, 1, 1).unwrap().day_ordinal(), 1); - assert_eq!(IFC::ymd(12020, 1, 1).unwrap().day_ordinal0(), 0); - - assert_eq!(IFC::ymd(12020, 1, 28).unwrap().day_ordinal(), 28); - assert_eq!(IFC::ymd(12020, 1, 28).unwrap().day_ordinal0(), 27); - - assert_eq!(IFC::ymd(12020, 2, 1).unwrap().day_ordinal(), 29); - assert_eq!(IFC::ymd(12020, 2, 1).unwrap().day_ordinal0(), 28); - - assert_eq!(IFC::ymd(12020, 3, 1).unwrap().day_ordinal(), 57); - assert_eq!(IFC::ymd(12020, 3, 1).unwrap().day_ordinal0(), 56); - - assert_eq!(IFC::ymd(12020, 4, 1).unwrap().day_ordinal(), 85); - assert_eq!(IFC::ymd(12020, 4, 1).unwrap().day_ordinal0(), 84); - - assert_eq!(IFC::ymd(12020, 5, 1).unwrap().day_ordinal(), 113); - assert_eq!(IFC::ymd(12020, 5, 1).unwrap().day_ordinal0(), 112); - - assert_eq!(IFC::ymd(12020, 6, 1).unwrap().day_ordinal(), 141); - assert_eq!(IFC::ymd(12020, 6, 1).unwrap().day_ordinal0(), 140); - - assert_eq!(IFC::leap_day(12020).unwrap().day_ordinal(), 169); - assert_eq!(IFC::leap_day(12020).unwrap().day_ordinal0(), 168); - - assert_eq!(IFC::ymd(12020, 7, 1).unwrap().day_ordinal(), 170); - assert_eq!(IFC::ymd(12020, 7, 1).unwrap().day_ordinal0(), 169); - - assert_eq!(IFC::ymd(12020, 8, 1).unwrap().day_ordinal(), 198); - assert_eq!(IFC::ymd(12020, 8, 1).unwrap().day_ordinal0(), 197); - - assert_eq!(IFC::ymd(12020, 9, 1).unwrap().day_ordinal(), 226); - assert_eq!(IFC::ymd(12020, 9, 1).unwrap().day_ordinal0(), 225); - - assert_eq!(IFC::ymd(12020, 10, 1).unwrap().day_ordinal(), 254); - assert_eq!(IFC::ymd(12020, 10, 1).unwrap().day_ordinal0(), 253); - - assert_eq!(IFC::ymd(12020, 11, 1).unwrap().day_ordinal(), 282); - assert_eq!(IFC::ymd(12020, 11, 1).unwrap().day_ordinal0(), 281); - - assert_eq!(IFC::ymd(12020, 12, 1).unwrap().day_ordinal(), 310); - assert_eq!(IFC::ymd(12020, 12, 1).unwrap().day_ordinal0(), 309); - - assert_eq!(IFC::ymd(12020, 13, 1).unwrap().day_ordinal(), 338); - assert_eq!(IFC::ymd(12020, 13, 1).unwrap().day_ordinal0(), 337); - - assert_eq!(IFC::ymd(12020, 13, 28).unwrap().day_ordinal(), 365); - assert_eq!(IFC::ymd(12020, 13, 28).unwrap().day_ordinal0(), 364); - - assert_eq!(IFC::year_day(12020).day_ordinal(), 366); - } - - #[test] - fn it_reports_ordinal_weeks() { - assert_eq!(IFC::ymd(12022, 1, 1).unwrap().week_ordinal(), 1); - assert_eq!(IFC::ymd(12022, 1, 1).unwrap().week_ordinal0(), 0); - assert_eq!(IFC::ymd(12022, 1, 4).unwrap().week_ordinal(), 1); - assert_eq!(IFC::ymd(12022, 1, 4).unwrap().week_ordinal0(), 0); - assert_eq!(IFC::ymd(12022, 1, 7).unwrap().week_ordinal(), 1); - assert_eq!(IFC::ymd(12022, 1, 7).unwrap().week_ordinal0(), 0); - assert_eq!(IFC::ymd(12022, 1, 8).unwrap().week_ordinal(), 2); - assert_eq!(IFC::ymd(12022, 1, 8).unwrap().week_ordinal0(), 1); - assert_eq!(IFC::ymd(12022, 2, 1).unwrap().week_ordinal(), 5); - assert_eq!(IFC::ymd(12022, 2, 1).unwrap().week_ordinal0(), 4); - assert_eq!(IFC::ymd(12022, 13, 28).unwrap().week_ordinal(), 52); - assert_eq!(IFC::ymd(12022, 13, 28).unwrap().week_ordinal0(), 51); - } - - #[test] - fn it_converts_from_gregorian() { - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 1, 1).unwrap()), - IFC::ymd(12022, 1, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 1, 2).unwrap()), - IFC::ymd(12022, 1, 2).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 1, 3).unwrap()), - IFC::ymd(12022, 1, 3).unwrap() - ); - assert_eq!( - IFC::from(chrono::NaiveDate::from_ymd_opt(2023, 01, 26).unwrap()), - IFC::ymd(2023, 1, 26).unwrap() - ); - assert_eq!( - IFC::from(chrono::NaiveDate::from_ymd_opt(2023, 01, 27).unwrap()), - IFC::ymd(2023, 1, 27).unwrap() - ); - assert_eq!( - IFC::from(chrono::NaiveDate::from_ymd_opt(2023, 01, 28).unwrap()), - IFC::ymd(2023, 1, 28).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 1, 29).unwrap()), - IFC::ymd(12022, 2, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 1, 30).unwrap()), - IFC::ymd(12022, 2, 2).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 2, 26).unwrap()), - IFC::ymd(12022, 3, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 3, 26).unwrap()), - IFC::ymd(12022, 4, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 4, 23).unwrap()), - IFC::ymd(12022, 5, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 5, 21).unwrap()), - IFC::ymd(12022, 6, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 6, 18).unwrap()), - IFC::ymd(12022, 7, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 7, 16).unwrap()), - IFC::ymd(12022, 8, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 8, 13).unwrap()), - IFC::ymd(12022, 9, 1).unwrap() - ); - assert_eq!( - IFC::from(chrono::NaiveDate::from_ymd_opt(2023, 08, 12).unwrap()), - IFC::ymd(2023, 8, 28).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 9, 10).unwrap()), - IFC::ymd(12022, 10, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 10, 8).unwrap()), - IFC::ymd(12022, 11, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 11, 5).unwrap()), - IFC::ymd(12022, 12, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 12, 3).unwrap()), - IFC::ymd(12022, 13, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12022, 12, 31).unwrap()), - IFC::YearDay(12022) - ); - } - - #[test] - fn it_converts_from_gregorian_on_leap_year() { - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 1, 1).unwrap()), - IFC::ymd(12020, 1, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 1, 29).unwrap()), - IFC::ymd(12020, 2, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 2, 26).unwrap()), - IFC::ymd(12020, 3, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 2, 28).unwrap()), - IFC::ymd(12020, 3, 3).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 2, 29).unwrap()), - IFC::ymd(12020, 3, 4).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 3, 1).unwrap()), - IFC::ymd(12020, 3, 5).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 3, 25).unwrap()), - IFC::ymd(12020, 4, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 4, 22).unwrap()), - IFC::ymd(12020, 5, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 5, 20).unwrap()), - IFC::ymd(12020, 6, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 6, 17).unwrap()), - IFC::LeapDay(12020) - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 6, 18).unwrap()), - IFC::ymd(12020, 7, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 7, 16).unwrap()), - IFC::ymd(12020, 8, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 8, 13).unwrap()), - IFC::ymd(12020, 9, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 9, 10).unwrap()), - IFC::ymd(12020, 10, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 10, 8).unwrap()), - IFC::ymd(12020, 11, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 11, 5).unwrap()), - IFC::ymd(12020, 12, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 12, 3).unwrap()), - IFC::ymd(12020, 13, 1).unwrap() - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd_opt(12020, 12, 31).unwrap()), - IFC::YearDay(12020) - ); - } - - #[test] - fn it_converts_to_gregorian() { - assert_eq!( - NaiveDate::from(IFC::ymd(12020, 1, 1).unwrap()), - NaiveDate::from_ymd_opt(12020, 1, 1).unwrap() - ); - - assert_eq!( - NaiveDate::from(IFC::leap_day(12020).unwrap()), - NaiveDate::from_ymd_opt(12020, 6, 17).unwrap() - ); - - assert_eq!( - NaiveDate::from(IFC::ymd(12020, 3, 4).unwrap()), - NaiveDate::from_ymd_opt(12020, 2, 29).unwrap() - ); - - assert_eq!( - NaiveDate::from(IFC::year_day(12020)), - NaiveDate::from_ymd_opt(12020, 12, 31).unwrap() - ); - } - - /* - #[test] - fn check_start_of_month() { - assert_eq!( - IFC::ymd(12019, 1, 1), - IFC { - year: 12019, - ordinal: 0, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 2, 1), - IFC { - year: 12019, - ordinal: 28, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 3, 1), - IFC { - year: 12019, - ordinal: 56, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 4, 1), - IFC { - year: 12019, - ordinal: 84, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 5, 1), - IFC { - year: 12019, - ordinal: 112, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 6, 1), - IFC { - year: 12019, - ordinal: 140, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 7, 1), - IFC { - year: 12019, - ordinal: 168, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 8, 1), - IFC { - year: 12019, - ordinal: 196, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 9, 1), - IFC { - year: 12019, - ordinal: 224, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 10, 1), - IFC { - year: 12019, - ordinal: 252, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 11, 1), - IFC { - year: 12019, - ordinal: 280, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 12, 1), - IFC { - year: 12019, - ordinal: 308, - leap_year: false - } - ); - assert_eq!( - IFC::ymd(12019, 13, 1), - IFC { - year: 12019, - ordinal: 336, - leap_year: false - } - ); - } - - #[test] - fn report_leap_day() {} - - #[test] - fn check_start_of_month_leap_year() { - assert_eq!( - IFC::ymd(12020, 1, 1), - IFC { - year: 12020, - ordinal: 0, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 2, 1), - IFC { - year: 12020, - ordinal: 28, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 3, 1), - IFC { - year: 12020, - ordinal: 56, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 4, 1), - IFC { - year: 12020, - ordinal: 84, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 5, 1), - IFC { - year: 12020, - ordinal: 112, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 6, 1), - IFC { - year: 12020, - ordinal: 140, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 6, 29), - IFC { - year: 12020, - ordinal: 168, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 7, 1), - IFC { - year: 12020, - ordinal: 169, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 8, 1), - IFC { - year: 12020, - ordinal: 197, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 9, 1), - IFC { - year: 12020, - ordinal: 225, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 10, 1), - IFC { - year: 12020, - ordinal: 253, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 11, 1), - IFC { - year: 12020, - ordinal: 281, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 12, 1), - IFC { - year: 12020, - ordinal: 309, - leap_year: true - } - ); - assert_eq!( - IFC::ymd(12020, 13, 1), - IFC { - year: 12020, - ordinal: 337, - leap_year: true - } - ); - } - #[test] - fn it_matches_january_1() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 1, 1)), - IFC::ymd(12019, 1, 1) - ); - } - - #[test] - fn it_matches_february_1() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 1, 29)), - IFC::ymd(12019, 2, 1) - ); - } - - #[test] - fn it_matches_sol_1() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 6, 18)), - IFC::ymd(12019, 7, 1) - ); - } - - #[test] - fn it_matches_year_day() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 12, 31)), - IFC::ymd(12019, 13, 29) - ); - } - - #[test] - fn it_matches_leap_day() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 6, 18)), - IFC::ymd(12019, 7, 1), - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 6, 17)), - IFC::ymd(12020, 6, 29), - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 6, 18)), - IFC::ymd(12020, 7, 1), - ); - assert_ne!(IFC::ymd(12020, 6, 29), IFC::ymd(12020, 7, 1)); - } - - #[test] - fn it_handles_gregorian_leap_day() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2019, 3, 1)), - IFC::ymd(12019, 3, 4) - ); - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 2, 29)), - IFC::ymd(12020, 3, 4) - ); - } - - #[test] - fn it_handles_days_between_leap_days() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 4, 8)), - IFC::ymd(12020, 4, 15), - ); - } - - #[test] - fn it_handles_days_after_ifc_leap_day() { - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 10, 8)), - IFC::ymd(12020, 11, 1), - ); - } - - #[test] - fn it_matches_year_day_in_leap_year() { - assert_eq!(NaiveDate::from_ymd(2020, 12, 31).ordinal(), 366); - assert_eq!( - IFC::from(NaiveDate::from_ymd(2020, 12, 31)), - IFC::ymd(12020, 13, 29) - ); - } - - #[test] - fn it_reports_correct_month() { - assert_eq!(IFC::ymd(12019, 1, 1).month(), 1); - assert_eq!(IFC::ymd(12019, 1, 1).month0(), 0); - - assert_eq!(IFC::ymd(12020, 6, 28).month(), 6); - assert_eq!(IFC::ymd(12020, 6, 28).month0(), 5); - - assert_eq!(IFC::ymd(12020, 7, 1).month(), 7); - assert_eq!(IFC::ymd(12020, 7, 1).month0(), 6); - - assert_eq!(IFC::ymd(12019, 13, 1).month(), 13); - assert_eq!(IFC::ymd(12019, 13, 1).month0(), 12); - } - - #[test] - fn it_reports_correct_day() { - assert_eq!(IFC::ymd(12019, 1, 1).day(), 1); - assert_eq!(IFC::ymd(12019, 1, 1).day0(), 0); - - assert_eq!(IFC::ymd(12020, 3, 1).day(), 1); - assert_eq!(IFC::ymd(12020, 3, 1).day0(), 0); - - assert_eq!(IFC::ymd(12020, 6, 28).day(), 28); - assert_eq!(IFC::ymd(12020, 6, 28).day0(), 27); - - assert_eq!(IFC::ymd(12020, 7, 1).day(), 1); - assert_eq!(IFC::ymd(12020, 7, 1).day0(), 0); - - assert_eq!(IFC::ymd(12019, 13, 1).day(), 1); - assert_eq!(IFC::ymd(12019, 13, 1).day0(), 0); - - assert_eq!(IFC::ymd(12019, 13, 29).day(), 29); - assert_eq!(IFC::ymd(12019, 13, 29).day0(), 28); - } - - #[test] - fn it_reports_correct_month_in_leap_year() { - assert_eq!(IFC::ymd(12020, 1, 1).month(), 1); - assert_eq!(IFC::ymd(12020, 1, 1).month0(), 0); - - assert_eq!(IFC::ymd(12020, 3, 1).month(), 3); - assert_eq!(IFC::ymd(12020, 3, 1).month0(), 2); - - assert_eq!(IFC::ymd(12020, 6, 29).month(), 6); - assert_eq!(IFC::ymd(12020, 6, 29).month0(), 5); - - assert_eq!(IFC::ymd(12020, 7, 1).month(), 7); - assert_eq!(IFC::ymd(12020, 7, 1).month0(), 6); - } - - #[test] - fn it_reports_correct_day_in_leap_year() { - assert_eq!(IFC::ymd(12019, 1, 1).day(), 1); - assert_eq!(IFC::ymd(12019, 1, 1).day0(), 0); - - assert_eq!(IFC::ymd(12020, 6, 28).day(), 28); - assert_eq!(IFC::ymd(12020, 6, 28).day0(), 27); - - assert_eq!(IFC::ymd(12020, 6, 29).day(), 29); - assert_eq!(IFC::ymd(12020, 6, 29).day0(), 28); - - assert_eq!(IFC::ymd(12020, 7, 1).day(), 1); - assert_eq!(IFC::ymd(12020, 7, 1).day0(), 0); - - assert_eq!(IFC::ymd(12019, 13, 1).day(), 1); - assert_eq!(IFC::ymd(12019, 13, 1).day0(), 0); - - assert_eq!(IFC::ymd(12019, 13, 29).day(), 29); - assert_eq!(IFC::ymd(12019, 13, 29).day0(), 28); - } - */ - - /* - #[test] - fn it_reports_correct_day_of_week() { - assert_eq!(IFC::ymd(12019, 1, 1).weekday(), DayOfWeek::Sunday); - assert_eq!(IFC::ymd(12019, 6, 1).weekday(), DayOfWeek::Sunday); - assert_eq!(IFC::ymd(12019, 6, 28).weekday(), DayOfWeek::Saturday); - assert_eq!(IFC::ymd(12019, 7, 1).weekday(), DayOfWeek::Sunday); - assert_eq!(IFC::ymd(12019, 13, 28).weekday(), DayOfWeek::Saturday); - assert_eq!(IFC::ymd(12019, 13, 29).weekday(), DayOfWeek::Saturday); - - assert_eq!(IFC::ymd(12020, 6, 28).weekday(), DayOfWeek::Saturday); - assert_eq!(IFC::ymd(12020, 6, 29).weekday(), DayOfWeek::Saturday); - assert_eq!(IFC::ymd(12020, 7, 1).weekday(), DayOfWeek::Sunday); - assert_eq!(IFC::ymd(12020, 13, 28).weekday(), DayOfWeek::Saturday); - assert_eq!(IFC::ymd(12020, 13, 29).weekday(), DayOfWeek::Saturday); - - assert_eq!(IFC::ymd(12022, 13, 31) - } - */ -} diff --git a/ifc/src/static/index.html b/ifc/src/static/index.html deleted file mode 100644 index 6b10716..0000000 --- a/ifc/src/static/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - {{month}} {{year}} - - - - -

IFC Fixed Calendar: {{month}}, {{year}} years after the invention of agriculture

- - - - - - - - - - - - - - - {{#weeks}} - - {{#days}} - - {{/days}} - - {{/weeks}} - -
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
{{day}}
- - - diff --git a/ifc/src/static/month.html b/ifc/src/static/month.html deleted file mode 100644 index 2544f32..0000000 --- a/ifc/src/static/month.html +++ /dev/null @@ -1,35 +0,0 @@ - - - {{month}} {{year}} - - - -

- IFC Fixed Calendar: {{month}}, {{year}} years after the invention of - agriculture -

- - - - - - - - - - - - - - - {{#weeks}} - - {{#days}} - - {{/days}} - - {{/weeks}} - -
SundayMondayTuesdayWednesdayThursdayFridaySaturday
{{day}}
- - diff --git a/ifc/src/static/out_of_time.html b/ifc/src/static/out_of_time.html deleted file mode 100644 index 0e5aa93..0000000 --- a/ifc/src/static/out_of_time.html +++ /dev/null @@ -1,12 +0,0 @@ - - - {{day_out_of_time}} {{year}} - - - -

- IFC Fixed Calendar: {{day_out_of_time}}, {{year}} years after the - invention of agriculture -

- - diff --git a/ifc/src/static/styles.css b/ifc/src/static/styles.css deleted file mode 100644 index 8b41587..0000000 --- a/ifc/src/static/styles.css +++ /dev/null @@ -1,18 +0,0 @@ - -table { - width: 98%; - border: 1px solid black; - border-collapse: collapse; -} - -th, td { - width: 14%; - font-family: sans-serif; - font-size: larger; - border: 1px solid black; - padding: 1em 0em 5em 1em; -} - -.today { - background-color: rgb(200, 200, 255); -} diff --git a/ifc/src/today.rs b/ifc/src/today.rs deleted file mode 100644 index 6d1657a..0000000 --- a/ifc/src/today.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2020-2023, Savanni D'Gerinel - -This file is part of the Luminescent Dreams Tools. - -Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with Lumeto. If not, see . -*/ - -extern crate chrono; -extern crate chrono_tz; -extern crate ifc as IFC; - -use chrono::{Datelike, Utc}; - -fn main() { - let d = IFC::IFC::from(Utc::today()); - println!("{} {}, {}", d.month(), d.day(), d.year()); -} diff --git a/ifc/src/web.rs b/ifc/src/web.rs deleted file mode 100644 index b08b95d..0000000 --- a/ifc/src/web.rs +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2020-2023, Savanni D'Gerinel - -This file is part of the Luminescent Dreams Tools. - -Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with Lumeto. If not, see . -*/ - -use chrono::{Datelike, Utc}; -use ifc as IFC; -use iron::headers; -use iron::middleware::Handler; -use iron::modifiers::Header; -use iron::prelude::*; -use iron::status; -use mustache::{compile_str, Template}; -use router::Router; -use serde::Serialize; - -pub const STYLES: &'static str = include_str!("static/styles.css"); -pub const INDEX: &'static str = include_str!("static/index.html"); - -pub struct IndexHandler { - pub template: Template, -} - -#[derive(Serialize)] -pub struct DayEntry { - day: u8, - highlight: String, -} - -#[derive(Serialize)] -pub struct Week { - days: Vec, -} - -impl Week { - fn new(start_day: u8, today: u8) -> Week { - Week { - days: (1..8) - .map(|d| DayEntry { - day: d + start_day, - highlight: if today == (d + start_day) { - String::from("today") - } else { - String::from("") - }, - }) - .collect(), - } - } -} - -#[derive(Serialize)] -pub struct IndexTemplateParams { - month: String, - year: i32, - weeks: Vec, -} - -impl IndexTemplateParams { - fn new(date: IFC::IFC) -> IndexTemplateParams { - let day = date.day() as u8; - IndexTemplateParams { - month: String::from(IFC::Month::from(date.month())), - year: date.year(), - weeks: (0..4).map(|wn| Week::new(wn * 7, day)).collect(), - } - } -} - -impl Handler for IndexHandler { - fn handle(&self, _: &mut Request) -> IronResult { - let d = IFC::IFC::from(Utc::today()); - Ok(Response::with(( - status::Ok, - Header(headers::ContentType(iron::mime::Mime( - iron::mime::TopLevel::Text, - iron::mime::SubLevel::Html, - vec![], - ))), - self.template - .render_to_string(&IndexTemplateParams::new(d)) - .expect("the template to render"), - ))) - } -} - -fn css(_: &mut Request) -> IronResult { - Ok(Response::with(( - status::Ok, - Header(headers::ContentType(iron::mime::Mime( - iron::mime::TopLevel::Text, - iron::mime::SubLevel::Css, - vec![], - ))), - STYLES, - ))) -} - -fn main() { - let mut router = Router::new(); - router.get( - "/", - IndexHandler { - template: compile_str(INDEX).expect("the template to compile"), - }, - "index", - ); - - router.get("/css", css, "styles"); - - Iron::new(router).http("127.0.0.1:3000").unwrap(); -} diff --git a/memorycache/src/lib.rs b/memorycache/src/lib.rs index 7ac9fb0..c8f305a 100644 --- a/memorycache/src/lib.rs +++ b/memorycache/src/lib.rs @@ -78,7 +78,7 @@ mod tests { }) .await; assert_eq!(value, Value(16)); - assert_eq!(*run.read().unwrap(), true); + assert!(*run.read().unwrap()); } #[tokio::test] @@ -97,6 +97,6 @@ mod tests { }) .await; assert_eq!(value, Value(15)); - assert_eq!(*run.read().unwrap(), false); + assert!(!(*run.read().unwrap())); } } diff --git a/nom-training/src/lib.rs b/nom-training/src/lib.rs index 4302bce..4cbc5fc 100644 --- a/nom-training/src/lib.rs +++ b/nom-training/src/lib.rs @@ -80,12 +80,12 @@ mod tests { use super::*; use cool_asserts::assert_matches; - const DATA: &'static str = "15"; + const DATA: &str = "15"; #[test] fn function() { let resp = parse_number_a::>() - .map(|val| Container(val)) + .map(Container) .parse(DATA); assert_matches!(resp, Ok((_, content)) => assert_eq!(content, Container(15)) @@ -95,7 +95,7 @@ mod tests { #[test] fn parser() { let resp = parse_number_b::>() - .map(|val| Container(val)) + .map(Container) .parse(DATA); assert_matches!(resp, Ok((_, content)) => assert_eq!(content, Container(15)) diff --git a/otg/core/src/goban.rs b/otg/core/src/goban.rs index ab0d0d8..e5077d1 100644 --- a/otg/core/src/goban.rs +++ b/otg/core/src/goban.rs @@ -396,8 +396,7 @@ mod test { (Coordinate { column: 17, row: 0 }, Color::White), (Coordinate { column: 17, row: 1 }, Color::White), (Coordinate { column: 18, row: 1 }, Color::White), - ] - .into_iter(), + ], ) .unwrap(); test(board); @@ -436,33 +435,32 @@ mod test { }, Color::Black, ), - ] - .into_iter(), + ], ) .unwrap(); assert!(board.group(&Coordinate { column: 18, row: 3 }).is_none()); assert_eq!( board .group(&Coordinate { column: 3, row: 3 }) - .map(|g| board.liberties(&g)), + .map(|g| board.liberties(g)), Some(4) ); assert_eq!( board .group(&Coordinate { column: 0, row: 3 }) - .map(|g| board.liberties(&g)), + .map(|g| board.liberties(g)), Some(3) ); assert_eq!( board .group(&Coordinate { column: 0, row: 0 }) - .map(|g| board.liberties(&g)), + .map(|g| board.liberties(g)), Some(2) ); assert_eq!( board .group(&Coordinate { column: 18, row: 9 }) - .map(|g| board.liberties(&g)), + .map(|g| board.liberties(g)), Some(3) ); assert_eq!( @@ -471,7 +469,7 @@ mod test { column: 18, row: 18 }) - .map(|g| board.liberties(&g)), + .map(|g| board.liberties(g)), Some(2) ); } @@ -614,7 +612,7 @@ mod test { for (board, coordinate, group, liberties) in test_cases { assert_eq!(board.group(&coordinate), group.as_ref()); assert_eq!( - board.group(&coordinate).map(|g| board.liberties(&g)), + board.group(&coordinate).map(|g| board.liberties(g)), liberties, "{:?}", coordinate @@ -688,11 +686,11 @@ mod test { fn validate_group_comparisons() { { let b1 = Goban::from_coordinates( - vec![(Coordinate { column: 7, row: 9 }, Color::White)].into_iter(), + vec![(Coordinate { column: 7, row: 9 }, Color::White)], ) .unwrap(); let b2 = Goban::from_coordinates( - vec![(Coordinate { column: 7, row: 9 }, Color::White)].into_iter(), + vec![(Coordinate { column: 7, row: 9 }, Color::White)], ) .unwrap(); @@ -704,16 +702,14 @@ mod test { vec![ (Coordinate { column: 7, row: 9 }, Color::White), (Coordinate { column: 8, row: 10 }, Color::White), - ] - .into_iter(), + ], ) .unwrap(); let b2 = Goban::from_coordinates( vec![ (Coordinate { column: 8, row: 10 }, Color::White), (Coordinate { column: 7, row: 9 }, Color::White), - ] - .into_iter(), + ], ) .unwrap(); @@ -732,8 +728,7 @@ mod test { (Coordinate { column: 10, row: 9 }, Color::Black), (Coordinate { column: 9, row: 8 }, Color::Black), (Coordinate { column: 9, row: 10 }, Color::Black), - ] - .into_iter(), + ], ) .unwrap(); diff --git a/otg/core/src/types.rs b/otg/core/src/types.rs index b2dc076..f72dc26 100644 --- a/otg/core/src/types.rs +++ b/otg/core/src/types.rs @@ -587,8 +587,7 @@ mod test { (Coordinate { column: 17, row: 0 }, Color::White), (Coordinate { column: 17, row: 1 }, Color::White), (Coordinate { column: 18, row: 1 }, Color::White), - ] - .into_iter(), + ], ) .unwrap(); state.current_player = Color::Black; @@ -612,8 +611,7 @@ mod test { (Coordinate { column: 10, row: 9 }, Color::Black), (Coordinate { column: 9, row: 8 }, Color::Black), (Coordinate { column: 9, row: 10 }, Color::Black), - ] - .into_iter(), + ], ) .unwrap(); diff --git a/otg/core/src/view_models/game_review.rs b/otg/core/src/view_models/game_review.rs index a598b2a..6445825 100644 --- a/otg/core/src/view_models/game_review.rs +++ b/otg/core/src/view_models/game_review.rs @@ -132,10 +132,10 @@ impl GameReviewViewModel { // the board state by applying the child. pub fn next_move(&self) { let mut inner = self.inner.write().unwrap(); - let current_position = inner.current_position.clone(); + let current_position = inner.current_position; match current_position { Some(current_position) => { - let current_id = current_position.clone(); + let current_id = current_position; let node = inner.game.trees[0].get(current_id).unwrap(); if let Some(next_id) = node.first_child().map(|child| child.node_id()) { inner.current_position = Some(next_id); @@ -180,7 +180,7 @@ mod test { where F: FnOnce(GameReviewViewModel), { - let records = sgf::parse_sgf_file(&Path::new("../../sgf/test_data/branch_test.sgf")) + let records = sgf::parse_sgf_file(Path::new("../../sgf/test_data/branch_test.sgf")) .expect("to successfully load the test file"); let record = records[0] .as_ref() diff --git a/otg/gtk/src/app_window.rs b/otg/gtk/src/app_window.rs index ca92ac6..0e2f5ca 100644 --- a/otg/gtk/src/app_window.rs +++ b/otg/gtk/src/app_window.rs @@ -18,7 +18,7 @@ use crate::{CoreApi, ResourceManager}; use adw::prelude::*; use glib::Propagation; -use gtk::{gdk::Key, EventControllerKey}; +use gtk::EventControllerKey; use otg_core::{ settings::{SettingsRequest, SettingsResponse}, CoreRequest, CoreResponse, GameReviewViewModel, diff --git a/otg/gtk/src/views/game_review.rs b/otg/gtk/src/views/game_review.rs index e799109..e88c50c 100644 --- a/otg/gtk/src/views/game_review.rs +++ b/otg/gtk/src/views/game_review.rs @@ -102,14 +102,8 @@ impl GameReview { } } - match *s.goban.borrow_mut() { - Some(ref mut goban) => goban.set_board_state(view.game_view()), - None => {} - }; - match *s.review_tree.borrow() { - Some(ref tree) => tree.queue_draw(), - None => {} - } + if let Some(ref mut goban) = *s.goban.borrow_mut() { goban.set_board_state(view.game_view()) }; + if let Some(ref tree) = *s.review_tree.borrow() { tree.queue_draw() } Propagation::Stop } }); diff --git a/screenplay/src/lib.rs b/screenplay/src/lib.rs index 9b7e5e0..1f7fe1b 100644 --- a/screenplay/src/lib.rs +++ b/screenplay/src/lib.rs @@ -66,7 +66,6 @@ impl Screenplay { /// This function currently returns no errors, instead panicing if anything goes wrong. pub fn new(gtk_app: >k::Application, screens: Vec) -> Result { let window = gtk::ApplicationWindow::new(gtk_app); - window.show(); let (sender, receiver) = gtk::glib::MainContext::channel(gtk::glib::Priority::DEFAULT); diff --git a/timezone-testing/src/lib.rs b/timezone-testing/src/lib.rs index 8ee8dc1..eb1fabd 100644 --- a/timezone-testing/src/lib.rs +++ b/timezone-testing/src/lib.rs @@ -1,11 +1,7 @@ #[cfg(test)] mod tests { use chrono::{DateTime, FixedOffset, NaiveDate, TimeZone}; - use chrono_tz::{ - America::{New_York, Phoenix}, - Tz, - US::Mountain, - }; + use chrono_tz::America::{New_York, Phoenix}; #[test] fn it_saves_with_offset() { @@ -37,7 +33,7 @@ mod tests { date.with_timezone(&New_York), FixedOffset::west_opt(4 * 60 * 60) .unwrap() - .with_ymd_and_hms(2023, 10, 14, 03, 0, 0) + .with_ymd_and_hms(2023, 10, 14, 3, 0, 0) .unwrap() ); assert_eq!( diff --git a/tree/src/lib.rs b/tree/src/lib.rs index 337a97f..0a4f72f 100644 --- a/tree/src/lib.rs +++ b/tree/src/lib.rs @@ -62,12 +62,14 @@ impl Tree { // Do a depth-first-search in order to get the path to a node. Start with a naive recursive // implementation, then switch to a stack-based implementation in order to avoid exceeding the // stack. + /* pub fn path_to(&self, f: F) -> Vec> where F: FnOnce(&T) -> bool + Copy, { unimplemented!() } + */ /// Convert each node of a tree from type T to type U pub fn map(&self, op: F) -> Tree @@ -206,17 +208,20 @@ mod tests { assert!(tree2.find_bfs(|val| *val == "17").is_some()); } + /* #[test] fn path_to_on_empty_tree_returns_empty() { let tree: Tree<&str> = Tree::default(); assert_eq!(tree.path_to(|val| *val == "i"), vec![]); } + */ // A // B G H // C I // D E F + /* #[test] fn it_can_find_a_path_to_a_node() { let (tree, a) = Tree::new("A"); @@ -232,4 +237,5 @@ mod tests { assert_eq!(tree.path_to(|val| *val == "z"), vec![]); assert_eq!(tree.path_to(|val| *val == "i"), vec![a, h, i]); } + */ } diff --git a/visions/server/src/asset_db.rs b/visions/server/src/asset_db.rs index c84e5c9..320bda4 100644 --- a/visions/server/src/asset_db.rs +++ b/visions/server/src/asset_db.rs @@ -139,14 +139,14 @@ pub mod mocks { } impl Assets for MemoryAssets { - fn assets<'a>(&'a self) -> AssetIter<'a> { + fn assets(&self) -> AssetIter<'_> { AssetIter(self.asset_paths.iter()) } fn get(&self, asset_id: AssetId) -> Result<(Mime, Vec), Error> { match (self.asset_paths.get(&asset_id), self.assets.get(&asset_id)) { (Some(path), Some(data)) => { - let mime = mime_guess::from_path(&path).first().unwrap(); + let mime = mime_guess::from_path(path).first().unwrap(); Ok((mime, data.to_vec())) } _ => Err(Error::NotFound), diff --git a/visions/server/src/core.rs b/visions/server/src/core.rs index e9224f6..f0628ad 100644 --- a/visions/server/src/core.rs +++ b/visions/server/src/core.rs @@ -10,7 +10,7 @@ use uuid::Uuid; use crate::{ asset_db::{self, AssetId, Assets}, - database::{CharacterId, Database, GameId, SessionId, UserId}, types::{AppError, FatalError, Game, GameOverview, Message, Rgb, Tabletop, User, UserProfile}, + database::{CharacterId, Database, GameId, SessionId, UserId}, types::{AppError, FatalError, GameOverview, Message, Rgb, Tabletop, User, UserProfile}, }; const DEFAULT_BACKGROUND_COLOR: Rgb = Rgb { @@ -225,7 +225,7 @@ impl Core { &self, id: CharacterId, ) -> ResultExt, AppError, FatalError> { - let mut state = self.0.write().await; + let state = self.0.write().await; let cr = state.db.character(&id).await; match cr { Ok(Some(row)) => ok(Some(row.data)), diff --git a/visions/server/src/database/mod.rs b/visions/server/src/database/mod.rs index 02b040b..a3ef97f 100644 --- a/visions/server/src/database/mod.rs +++ b/visions/server/src/database/mod.rs @@ -195,7 +195,7 @@ mod test { use super::*; - const SOREN: &'static str = r#"{ "type_": "Candela", "name": "Soren Jensen", "pronouns": "he/him", "circle": "Circle of the Bluest Sky", "style": "dapper gentleman", "catalyst": "a cursed book", "question": "What were the contents of that book?", "nerve": { "type_": "nerve", "drives": { "current": 1, "max": 2 }, "resistances": { "current": 0, "max": 3 }, "move": { "gilded": false, "score": 2 }, "strike": { "gilded": false, "score": 1 }, "control": { "gilded": true, "score": 0 } }, "cunning": { "type_": "cunning", "drives": { "current": 1, "max": 1 }, "resistances": { "current": 0, "max": 3 }, "sway": { "gilded": false, "score": 0 }, "read": { "gilded": false, "score": 0 }, "hide": { "gilded": false, "score": 0 } }, "intuition": { "type_": "intuition", "drives": { "current": 0, "max": 0 }, "resistances": { "current": 0, "max": 3 }, "survey": { "gilded": false, "score": 0 }, "focus": { "gilded": false, "score": 0 }, "sense": { "gilded": false, "score": 0 } }, "role": "Slink", "role_abilities": [ "Scout: If you have time to observe a location, you can spend 1 Intuition to ask a question: What do I notice here that others do not see? What in this place might be of use to us? What path should we follow?" ], "specialty": "Detective", "specialty_abilities": [ "Mind Palace: When you want to figure out how two clues might relate or what path they should point you towards, burn 1 Intution resistance. The GM will give you the information you have deduced." ] }"#; + const SOREN: &str = r#"{ "type_": "Candela", "name": "Soren Jensen", "pronouns": "he/him", "circle": "Circle of the Bluest Sky", "style": "dapper gentleman", "catalyst": "a cursed book", "question": "What were the contents of that book?", "nerve": { "type_": "nerve", "drives": { "current": 1, "max": 2 }, "resistances": { "current": 0, "max": 3 }, "move": { "gilded": false, "score": 2 }, "strike": { "gilded": false, "score": 1 }, "control": { "gilded": true, "score": 0 } }, "cunning": { "type_": "cunning", "drives": { "current": 1, "max": 1 }, "resistances": { "current": 0, "max": 3 }, "sway": { "gilded": false, "score": 0 }, "read": { "gilded": false, "score": 0 }, "hide": { "gilded": false, "score": 0 } }, "intuition": { "type_": "intuition", "drives": { "current": 0, "max": 0 }, "resistances": { "current": 0, "max": 3 }, "survey": { "gilded": false, "score": 0 }, "focus": { "gilded": false, "score": 0 }, "sense": { "gilded": false, "score": 0 } }, "role": "Slink", "role_abilities": [ "Scout: If you have time to observe a location, you can spend 1 Intuition to ask a question: What do I notice here that others do not see? What in this place might be of use to us? What path should we follow?" ], "specialty": "Detective", "specialty_abilities": [ "Mind Palace: When you want to figure out how two clues might relate or what path they should point you towards, burn 1 Intution resistance. The GM will give you the information you have deduced." ] }"#; fn setup_db() -> (DiskDb, GameId) { let no_path: Option = None; @@ -221,7 +221,7 @@ mod test { #[tokio::test] async fn it_can_retrieve_a_character_through_conn() { let memory_db: Option = None; - let mut conn = DbConn::new(memory_db); + let conn = DbConn::new(memory_db); assert_matches!(conn.character(&CharacterId::from("1")).await, Ok(None)); } diff --git a/visions/server/src/handlers/game_management.rs b/visions/server/src/handlers/game_management.rs index 9e72bc7..721880a 100644 --- a/visions/server/src/handlers/game_management.rs +++ b/visions/server/src/handlers/game_management.rs @@ -1,7 +1,4 @@ -use axum::{ - http::{HeaderMap, StatusCode}, - Json, -}; +use axum::http::HeaderMap; use result_extended::ResultExt; use serde::{Deserialize, Serialize}; diff --git a/visions/server/src/handlers/mod.rs b/visions/server/src/handlers/mod.rs index 19950cd..31dda81 100644 --- a/visions/server/src/handlers/mod.rs +++ b/visions/server/src/handlers/mod.rs @@ -3,7 +3,6 @@ mod user_management; use axum::{http::StatusCode, Json}; use futures::Future; pub use game_management::*; -use typeshare::typeshare; pub use user_management::*; use result_extended::ResultExt; @@ -16,7 +15,7 @@ use crate::{ #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct HealthCheck { - pub admin_enabled: bool, + pub ok: bool, } pub async fn wrap_handler(f: F) -> (StatusCode, Json>) @@ -46,10 +45,10 @@ where pub async fn healthcheck(core: Core) -> Vec { match core.status().await { ResultExt::Ok(s) => serde_json::to_vec(&HealthCheck { - admin_enabled: s.admin_enabled, + ok: s.admin_enabled, }) .unwrap(), - ResultExt::Err(_) => serde_json::to_vec(&HealthCheck { admin_enabled: false }).unwrap(), + ResultExt::Err(_) => serde_json::to_vec(&HealthCheck { ok: false }).unwrap(), ResultExt::Fatal(err) => panic!("{}", err), } } diff --git a/visions/server/src/handlers/user_management.rs b/visions/server/src/handlers/user_management.rs index dcbad23..680fce0 100644 --- a/visions/server/src/handlers/user_management.rs +++ b/visions/server/src/handlers/user_management.rs @@ -1,5 +1,5 @@ use axum::{ - http::{HeaderMap, StatusCode}, + http::HeaderMap, Json, }; use futures::Future;