Some autoated fixes.

This commit is contained in:
Nahuel Lofeudo 2026-04-27 21:02:41 +01:00
parent 431f21a8b8
commit ca6857dda9
5 changed files with 9 additions and 10 deletions

View File

@ -1,12 +1,12 @@
mod loader; mod loader;
mod utils; mod utils;
pub mod structs; pub mod structs;
use chrono::{DateTime, Local, NaiveDate, NaiveDateTime}; use chrono::{DateTime, Local};
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
fs::File, fs::File,
}; };
use gtfs_structures::{Agency, Calendar, CalendarDate, Exception, RawStopTime, RawTrip, Route, Stop, TimepointType, Trip}; use gtfs_structures::{Agency, Calendar, CalendarDate, Exception, RawStopTime, RawTrip, Route, Stop};
use crate::gtfs::{loader::load_gtfs, structs::{Arrival, Preferences}}; use crate::gtfs::{loader::load_gtfs, structs::{Arrival, Preferences}};
@ -32,7 +32,7 @@ pub struct Gtfs {
impl Gtfs { impl Gtfs {
pub fn get_next_arrivals_for(&self, target_datetime: &DateTime<Local>) -> Box<Vec<Arrival>> { pub fn get_next_arrivals_for(&self, target_datetime: &DateTime<Local>) -> Box<Vec<Arrival<'_>>> {
let naive_target = target_datetime.naive_local(); let naive_target = target_datetime.naive_local();
let target_date = naive_target.date(); let target_date = naive_target.date();
@ -64,7 +64,7 @@ impl Gtfs {
// Find the trips happening on these calendars // Find the trips happening on these calendars
let mut trips: HashMap<&String, &RawTrip> = HashMap::new(); let mut trips: HashMap<&String, &RawTrip> = HashMap::new();
for (id, trip) in self.trips.iter() { for (_id, trip) in self.trips.iter() {
if active_service_ids.contains(&trip.service_id) { if active_service_ids.contains(&trip.service_id) {
trips.insert(&trip.id, trip); trips.insert(&trip.id, trip);
} }
@ -73,7 +73,7 @@ impl Gtfs {
// Finally, find the arrivals for the active trips on the chosen stops // Finally, find the arrivals for the active trips on the chosen stops
let mut arrivals: Vec<Arrival> = Vec::new(); let mut arrivals: Vec<Arrival> = Vec::new();
let current_timestamp = target_datetime.timestamp(); let current_timestamp = target_datetime.timestamp();
for (id, stop_time) in self.stop_times.iter() { for (_id, stop_time) in self.stop_times.iter() {
if trips.contains_key(&stop_time.trip_id) { if trips.contains_key(&stop_time.trip_id) {
let stop_timestamp = stop_time.departure_time.or(stop_time.arrival_time).unwrap(); let stop_timestamp = stop_time.departure_time.or(stop_time.arrival_time).unwrap();
if current_timestamp < stop_timestamp.into() { if current_timestamp < stop_timestamp.into() {

View File

@ -1,6 +1,6 @@
use std::collections::{HashSet}; use std::collections::{HashSet};
use gtfs_structures::{TimepointType, Route, Stop}; use gtfs_structures::{Route, Stop};
// This is to store the preferences for the GTFS(-R) side of the code. // This is to store the preferences for the GTFS(-R) side of the code.
pub struct Preferences { pub struct Preferences {

View File

@ -1,6 +1,6 @@
mod gtfs; mod gtfs;
mod renderer; mod renderer;
use std::{collections::HashSet, process, thread, time::SystemTime}; use std::{collections::HashSet, process, time::SystemTime};
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
use sdl3::event::Event; use sdl3::event::Event;

View File

@ -1,7 +1,7 @@
pub mod structs; pub mod structs;
use sdl3::{Sdl, pixels::Color, rect::Rect, render::Canvas, sys::metadata::render, ttf::Font, video::Window}; use sdl3::{Sdl, pixels::Color, rect::Rect, render::Canvas, ttf::Font, video::Window};
use structs::{Prefs}; use structs::{Prefs};
pub struct Screen<'a> { pub struct Screen<'a> {
@ -35,7 +35,7 @@ impl Screen<'_> {
/// Initialize video, allocate buffers and load fonts /// Initialize video, allocate buffers and load fonts
/// Based on https://github.com/vhspace/sdl3-rs/blob/master/examples/ttf-demo.rs /// Based on https://github.com/vhspace/sdl3-rs/blob/master/examples/ttf-demo.rs
pub fn init(prefs: &Prefs) -> Screen { pub fn init(prefs: &Prefs) -> Screen<'_> {
// Initialize the screen // Initialize the screen
let sdl_context = sdl3::init().unwrap(); let sdl_context = sdl3::init().unwrap();
let video_subsys = sdl_context.video().unwrap(); let video_subsys = sdl_context.video().unwrap();

View File

@ -1,4 +1,3 @@
use sdl3::{render::Canvas, ttf::Font, video::Window};
pub struct Prefs { pub struct Prefs {
pub font_path: String, pub font_path: String,