Skip to content

Commit 6811049

Browse files
committed
Fix: Use &self argument for various unit methods, not self
If we use `self`, without the ampersand, then calling the method will consume the struct (like moving it) and it won't be usable again.
1 parent f6ff308 commit 6811049

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/units.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ macro_rules! base_unit_struct {
6060
}
6161
impl $name {
6262
/// Returns the underlying f64 value.
63-
pub fn value(self) -> f64 {
63+
pub fn value(&self) -> f64 {
6464
self.0
6565
}
6666
/// Returns true if the value is a normal number.
67-
pub fn is_normal(self) -> bool {
67+
pub fn is_normal(&self) -> bool {
6868
self.0.is_normal()
6969
}
7070
/// Returns true if the value is finite.
71-
pub fn is_finite(self) -> bool {
71+
pub fn is_finite(&self) -> bool {
7272
self.0.is_finite()
7373
}
7474
/// Returns the absolute value of this unit.
75-
pub fn abs(self) -> Self {
75+
pub fn abs(&self) -> Self {
7676
$name(self.0.abs())
7777
}
7878
}

0 commit comments

Comments
 (0)