Fix a lot of very simple, easy warnings

This commit is contained in:
Savanni D'Gerinel 2025-01-18 22:38:10 -05:00
parent f59c3544b4
commit 81143f0b9c
48 changed files with 144 additions and 1874 deletions

9
Cargo.lock generated
View File

@ -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"

View File

@ -22,7 +22,6 @@ members = [
"gm-control-panel",
"hex-grid",
"icon-test",
"ifc",
"memorycache",
"nom-training",
"otg/core",

View File

@ -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) => {
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) => {
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) => {
if let Some(event) = self.ui.check_event(time) {
self.update_state(event);
self.update_animation(time);
}
None => {}
};
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);
}
}

View File

@ -45,6 +45,12 @@ glib::wrapper! {
pub struct DashboardLights(ObjectSubclass<DashboardLightsPrivate>) @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<BikeLightsPrivate>) @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();

View File

@ -40,6 +40,12 @@ macro_rules! define_config {
values: std::collections::HashMap<ConfigName, ConfigOption>,
}
impl Default for Config {
fn default() -> Self {
Self::new()
}
}
impl Config {
pub fn new() -> Self {
Self {

View File

@ -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<AxialAddr> = 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);
}
}
}

View File

@ -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<Step>);
impl Script {
@ -51,7 +52,7 @@ impl Script {
Ok(Self(script))
}
fn iter<'a>(&'a self) -> impl Iterator<Item = &'a Step> {
fn iter(&self) -> impl Iterator<Item = &'_ Step> {
self.0.iter()
}
@ -60,11 +61,6 @@ impl Script {
}
}
impl Default for Script {
fn default() -> Self {
Self(vec![])
}
}
impl Index<usize> 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<dyn Animation> {
@ -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.;

View File

@ -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};

View File

@ -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<String>
lines.push(line.clone());
}
}
if line.len() > 0 {
if !line.is_empty() {
lines.push(line);
}
lines

View File

@ -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}}";

View File

@ -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",

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
use types::{Recordable, Timestamp};
use crate::types::{Recordable, Timestamp};
/// This trait is used for constructing queries for searching the database.
pub trait Criteria {

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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

View File

@ -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));

View File

@ -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),
}

View File

@ -443,7 +443,7 @@ mod test {
async fn put_record(&self, record: TraxRecord) -> Result<RecordId, WriteError> {
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),

View File

@ -144,7 +144,7 @@ impl HistoricalView {
let mut model = gio::ListStore::new::<Date>();
let mut days = interval.days().map(Date::new).collect::<Vec<Date>>();
days.reverse();
model.extend(days.into_iter());
model.extend(days);
self.imp()
.list_view
.set_model(Some(&gtk::NoSelection::new(Some(model))));

View File

@ -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,
};

View File

@ -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::<LanguageIdentifier>().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::<LanguageIdentifier>().unwrap();
let en_id = "en".parse::<LanguageIdentifier>().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::<LanguageIdentifier>().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::<LanguageIdentifier>().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");

View File

@ -7,8 +7,8 @@ use std::iter::Iterator;
#[derive(Clone)]
pub struct ApplicationWindow {
pub window: adw::ApplicationWindow,
pub layout: gtk::FlowBox,
pub playlists: Vec<PlaylistCard>,
// pub layout: gtk::FlowBox,
// pub playlists: Vec<PlaylistCard>,
}
impl ApplicationWindow {
@ -57,8 +57,10 @@ impl ApplicationWindow {
Self {
window,
/*
layout,
playlists,
*/
}
}
}

View File

@ -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<String> {
let st = self.internal.read().unwrap();
(*st).device_list.clone()
st.device_list.clone()
}
}

View File

@ -107,8 +107,6 @@ impl ObjectSubclass for HexGridWindowPrivate {
layout.append(&drawing_area);
layout.append(&sidebar);
layout.show();
Self {
drawing_area,
hex_address,

400
ifc/Cargo.lock generated
View File

@ -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"

View File

@ -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 <savanni@luminescent-dreams.com>"]
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" }

View File

@ -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<NaiveDate>`
* `Datelike`

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
<html>
<head>
<title> {{month}} {{year}} </title>
<link href="/css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<h1> IFC Fixed Calendar: {{month}}, {{year}} years after the invention of agriculture </h1>
<table>
<thead>
<tr>
<th> Sunday </th>
<th> Monday </th>
<th> Tuesday </th>
<th> Wednesday </th>
<th> Thursday </th>
<th> Friday </th>
<th> Saturday </th>
</tr>
</thead>
<tbody>
{{#weeks}}
<tr>
{{#days}}
<td class="{{highlight}}"> {{day}} </td>
{{/days}}
</tr>
{{/weeks}}
</tbody>
</table>
</body>
</html>

View File

@ -1,35 +0,0 @@
<html>
<head>
<title>{{month}} {{year}}</title>
<link href="/css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<h1>
IFC Fixed Calendar: {{month}}, {{year}} years after the invention of
agriculture
</h1>
<table>
<thead>
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
</thead>
<tbody>
{{#weeks}}
<tr>
{{#days}}
<td class="{{highlight}}">{{day}}</td>
{{/days}}
</tr>
{{/weeks}}
</tbody>
</table>
</body>
</html>

View File

@ -1,12 +0,0 @@
<html>
<head>
<title>{{day_out_of_time}} {{year}}</title>
<link href="/css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<h1>
IFC Fixed Calendar: {{day_out_of_time}}, {{year}} years after the
invention of agriculture
</h1>
</body>
</html>

View File

@ -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);
}

View File

@ -1,22 +0,0 @@
/*
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
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 <https://www.gnu.org/licenses/>.
*/
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());
}

View File

@ -1,119 +0,0 @@
/*
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
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 <https://www.gnu.org/licenses/>.
*/
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<DayEntry>,
}
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<Week>,
}
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<Response> {
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<Response> {
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();
}

View File

@ -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()));
}
}

View File

@ -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::<nom::error::VerboseError<&str>>()
.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::<nom::error::VerboseError<&str>>()
.map(|val| Container(val))
.map(Container)
.parse(DATA);
assert_matches!(resp, Ok((_, content)) =>
assert_eq!(content, Container(15))

View File

@ -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();

View File

@ -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();

View File

@ -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()

View File

@ -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,

View File

@ -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
}
});

View File

@ -66,7 +66,6 @@ impl Screenplay {
/// This function currently returns no errors, instead panicing if anything goes wrong.
pub fn new(gtk_app: &gtk::Application, screens: Vec<Screen>) -> Result<Self, Error> {
let window = gtk::ApplicationWindow::new(gtk_app);
window.show();
let (sender, receiver) = gtk::glib::MainContext::channel(gtk::glib::Priority::DEFAULT);

View File

@ -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!(

View File

@ -62,12 +62,14 @@ impl<T> Tree<T> {
// 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<F>(&self, f: F) -> Vec<Node<T>>
where
F: FnOnce(&T) -> bool + Copy,
{
unimplemented!()
}
*/
/// Convert each node of a tree from type T to type U
pub fn map<F, U>(&self, op: F) -> Tree<U>
@ -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]);
}
*/
}

View File

@ -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<u8>), 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),

View File

@ -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<Option<serde_json::Value>, 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)),

View File

@ -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<PathBuf> = None;
@ -221,7 +221,7 @@ mod test {
#[tokio::test]
async fn it_can_retrieve_a_character_through_conn() {
let memory_db: Option<PathBuf> = None;
let mut conn = DbConn::new(memory_db);
let conn = DbConn::new(memory_db);
assert_matches!(conn.character(&CharacterId::from("1")).await, Ok(None));
}

View File

@ -1,7 +1,4 @@
use axum::{
http::{HeaderMap, StatusCode},
Json,
};
use axum::http::HeaderMap;
use result_extended::ResultExt;
use serde::{Deserialize, Serialize};

View File

@ -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, A, Fut>(f: F) -> (StatusCode, Json<Option<A>>)
@ -46,10 +45,10 @@ where
pub async fn healthcheck(core: Core) -> Vec<u8> {
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),
}
}

View File

@ -1,5 +1,5 @@
use axum::{
http::{HeaderMap, StatusCode},
http::HeaderMap,
Json,
};
use futures::Future;