Skip to content

Commit 531c81f

Browse files
Merge pull request #25 from OSCPS-Project/linter_fix
Linter fix
2 parents 22aa6a3 + 5eb63f9 commit 531c81f

3 files changed

Lines changed: 19 additions & 21 deletions

File tree

oscps-lib/src/blocks.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub trait MassBalance {
4242
let mass_in_kg = mass_in.get::<kilogram>();
4343
let mass_out_kg = mass_out.get::<kilogram>();
4444
let mass_difference = mass_in_kg - mass_out_kg;
45-
return mass_difference <= TOLERENCE_MASS.get::<kilogram>();
45+
mass_difference <= TOLERENCE_MASS.get::<kilogram>()
4646
}
4747
}
4848

@@ -62,9 +62,7 @@ pub trait EnergyBalance {
6262
let energy_in_joules = energy_in.get::<joule>();
6363
let energy_out_joules = energy_out.get::<joule>();
6464
let energy_difference = energy_in_joules - energy_out_joules;
65-
let within_threshold = energy_difference <=
66-
TOLERENCE_ENERGY.get::<joule>();
67-
return within_threshold;
65+
energy_difference <= TOLERENCE_ENERGY.get::<joule>()
6866
}
6967
}
7068

@@ -106,15 +104,15 @@ impl Mixer {
106104
in_streams_mass: Vec<connector::Mconnector>,
107105
in_streams_energy: Vec<connector::Econnector>,
108106
) -> Mixer {
109-
return Mixer {
107+
Mixer {
110108
block_id: id,
111109
x_cord,
112110
y_cord,
113111
input_streams_mass: in_streams_mass,
114112
input_streams_energy: in_streams_energy,
115113
outlet_stream_mass: None,
116114
outlet_stream_energy: None,
117-
};
115+
}
118116
}
119117

120118
/// Execute the mixer block (calculate balances, output streams, etc)
@@ -143,19 +141,19 @@ impl Mixer {
143141
let mut mass_flow_sum: f64 = 0.0;
144142

145143
for stream in &self.input_streams_mass {
146-
mass_flow_sum = mass_flow_sum + stream.m_flow_total;
144+
mass_flow_sum += stream.m_flow_total;
147145
}
148-
return Some(mass_flow_sum);
146+
Some(mass_flow_sum)
149147
}
150148

151149
/// Determines the total energy flowing through the block
152150
fn compute_outlet_energy_flows(&self) -> Option<f64> {
153151
let mut energy_flow_sum: f64 = 0.0;
154152

155153
for stream in &self.input_streams_energy {
156-
energy_flow_sum = energy_flow_sum + stream.energy_flow_total;
154+
energy_flow_sum += stream.energy_flow_total;
157155
}
158-
return Some(energy_flow_sum);
156+
Some(energy_flow_sum)
159157
}
160158

161159
/// Determines the phase fractions of the output using thermodynamics.

oscps-lib/src/component.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Chemical {
5454
break;
5555
},
5656
_ => {
57-
request_counter = request_counter + 1;
57+
request_counter += 1;
5858
thread::sleep(Duration::from_secs(10));
5959
}
6060
};
@@ -63,19 +63,19 @@ impl Chemical {
6363
// let cid_vec = pubchem_chemical_object.cids().unwrap();
6464
let cid: i32 = cid_vec.unwrap()[0];
6565
let prop = ChemicalProperties::new(cid).unwrap();
66-
return Ok(Chemical {
66+
Ok(Chemical {
6767
pubchem_obj: pubchem_chemical_object,
6868
properties: prop,
69-
});
69+
})
7070
}
7171
/// Returns the pubchem object for the compound.
7272
pub fn get_pubchem_obj(&self) -> &pubchem::Compound {
73-
return &self.pubchem_obj;
73+
&self.pubchem_obj
7474
}
7575

7676
/// Returns the "ChemicalProperties" object for the "Chemical" object.
7777
pub fn get_properties(&self) -> &ChemicalProperties {
78-
return &self.properties;
78+
&self.properties
7979
}
8080
}
8181

@@ -97,12 +97,12 @@ impl ChemicalProperties {
9797
/// Constructor for the ChemicalProperties struct.
9898
pub fn new(cid: i32) -> Result<Self> {
9999
println!("Recieving information for compound/element {cid}");
100-
return Ok(ChemicalProperties {
100+
Ok(ChemicalProperties {
101101
molar_mass: 0.0, // kg/mol
102102
critical_temp: 0.0, // K
103103
critical_pressure: 0.0, // Pa
104104
acentric_factor: 0.0,
105-
});
105+
})
106106
}
107107
}
108108

oscps-lib/src/connector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ pub struct Mconnector {
2222
impl Mconnector {
2323
/// Constructor for a connector.
2424
pub fn new(id: String) -> Mconnector {
25-
return Mconnector {
25+
Mconnector {
2626
m_conn_id: id,
2727
m_flow_total: 0.0,
28-
};
28+
}
2929
}
3030
}
3131

@@ -46,9 +46,9 @@ pub struct Econnector {
4646
impl Econnector {
4747
/// Constructor for a connector.
4848
pub fn new(id: String) -> Econnector {
49-
return Econnector {
49+
Econnector {
5050
e_conn_id: id,
5151
energy_flow_total: 0.0,
52-
};
52+
}
5353
}
5454
}

0 commit comments

Comments
 (0)