aboutsummaryrefslogtreecommitdiffstats
path: root/src/mass.rs
diff options
context:
space:
mode:
authorsam-anthony <samanthony6@protonmail.com>2022-01-26 06:37:29 -0330
committersam-anthony <samanthony6@protonmail.com>2022-01-26 06:37:29 -0330
commitb45ddda0fda44ffb5e4ffbfe94b4d293b06d883e (patch)
treeb0167611d285da4302b575ae35f93ee4902eb3dd /src/mass.rs
parenteb55242f08fcd4a9a3fdcc8de1110999614c8813 (diff)
downloadvolute-b45ddda0fda44ffb5e4ffbfe94b4d293b06d883e.zip
basic input handling
Diffstat (limited to 'src/mass.rs')
-rw-r--r--src/mass.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/mass.rs b/src/mass.rs
deleted file mode 100644
index 9c57f16..0000000
--- a/src/mass.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-pub struct Mass(f64); // Base unit is grams
-
-impl Mass {
- /* constructors */
- pub fn from_grams(grams: f64) -> Mass {
- Mass(grams)
- }
-
- pub fn from_kilograms(kilos: f64) -> Mass {
- Mass(kilos / 1000.)
- }
-
- pub fn from_moles(moles: f64, molar_mass: f64) -> Mass {
- let kilos = moles * molar_mass;
- Mass::from_kilograms(kilos)
- }
-
- /* metric */
- pub fn as_grams(&self) -> f64 {
- self.0
- }
-
- pub fn as_kilograms(&self) -> f64 {
- self.0 / 1000.
- }
-
- /* imperial */
- pub fn as_pounds(&self) -> f64 {
- self.0 * 0.002204623
- }
-}