Skip to content

Commit

Permalink
addressed warnings and hints
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 7, 2025
1 parent b78cd3a commit 956208c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rust/altrios-core/src/track/link/link_idx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'de> Deserialize<'de> for LinkIdx {
D: Deserializer<'de>,
{
struct LinkIdxVisitor;
impl<'de> Visitor<'de> for LinkIdxVisitor {
impl Visitor<'_> for LinkIdxVisitor {
type Value = LinkIdx;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
1 change: 0 additions & 1 deletion rust/altrios-core/src/train/set_speed_train_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ impl SetSpeedTrainSim {
/// - drag
/// - inertia
/// - acceleration
/// (some of these aren't implemented yet)
pub fn solve_required_pwr(&mut self, dt: si::Time) -> anyhow::Result<()> {
// This calculates the maximum power from loco based on current power, ramp rate, and dt of model. will return 0 if this is negative.
let pwr_pos_max =
Expand Down
20 changes: 8 additions & 12 deletions rust/altrios-core/src/train/train_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ pub struct TrainConfig {

impl SerdeAPI for TrainConfig {
fn init(&mut self) -> anyhow::Result<()> {
match &self.cd_area_vec {
Some(dcv) => {
// TODO: account for locomotive drag here, too
ensure!(dcv.len() as u32 == self.cars_total());
}
None => {}
if let Some(dcv) = &self.cd_area_vec {
// TODO: account for locomotive drag here, too
ensure!(dcv.len() as u32 == self.cars_total());
};
Ok(())
}
Expand Down Expand Up @@ -915,12 +912,11 @@ pub fn run_speed_limit_train_sims(
.loco_vec
.iter_mut()
.zip(departing_soc_pct_vec)
.for_each(
|(loco, soc)| match &mut loco.reversible_energy_storage_mut() {
Some(loco) => loco.state.soc = soc * uc::R,
None => {}
},
);
.for_each(|(loco, soc)| {
if let Some(loco) = &mut loco.reversible_energy_storage_mut() {
loco.state.soc = soc * uc::R
}
});
let _ = sim
.walk_timed_path(&network, &timed_paths[idx])
.map_err(|err| err.context(format!("train sim idx: {}", idx)));
Expand Down

0 comments on commit 956208c

Please sign in to comment.