Some autoated fixes.
This commit is contained in:
parent
431f21a8b8
commit
ca6857dda9
|
|
@ -1,12 +1,12 @@
|
|||
mod loader;
|
||||
mod utils;
|
||||
pub mod structs;
|
||||
use chrono::{DateTime, Local, NaiveDate, NaiveDateTime};
|
||||
use chrono::{DateTime, Local};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
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}};
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ pub struct 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 target_date = naive_target.date();
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ impl Gtfs {
|
|||
|
||||
// Find the trips happening on these calendars
|
||||
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) {
|
||||
trips.insert(&trip.id, trip);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ impl Gtfs {
|
|||
// Finally, find the arrivals for the active trips on the chosen stops
|
||||
let mut arrivals: Vec<Arrival> = Vec::new();
|
||||
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) {
|
||||
let stop_timestamp = stop_time.departure_time.or(stop_time.arrival_time).unwrap();
|
||||
if current_timestamp < stop_timestamp.into() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
pub struct Preferences {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod gtfs;
|
||||
mod renderer;
|
||||
use std::{collections::HashSet, process, thread, time::SystemTime};
|
||||
use std::{collections::HashSet, process, time::SystemTime};
|
||||
use chrono::{DateTime, Local};
|
||||
use sdl3::event::Event;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
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};
|
||||
|
||||
pub struct Screen<'a> {
|
||||
|
|
@ -35,7 +35,7 @@ impl Screen<'_> {
|
|||
|
||||
/// Initialize video, allocate buffers and load fonts
|
||||
/// 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
|
||||
let sdl_context = sdl3::init().unwrap();
|
||||
let video_subsys = sdl_context.video().unwrap();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use sdl3::{render::Canvas, ttf::Font, video::Window};
|
||||
|
||||
pub struct Prefs {
|
||||
pub font_path: String,
|
||||
|
|
|
|||
Loading…
Reference in New Issue