Skip to content

Commit b0fd749

Browse files
authored
Added sum to SIObject (#112)
1 parent 29cff86 commit b0fd749

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

si-units/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Added
1212
- Added `ATM` and `POISE` as additional units for pressure and viscosity.
13+
- Added `sum` for `SIObject`s that can be summed. [#111](https://github.com/itt-ustutt/quantity/pull/111)
1314

1415
### Fixed
1516
- Fixed the String representation of non-scalar mass quantities. [#111](https://github.com/itt-ustutt/quantity/pull/111)

si-units/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ impl PySIObject {
297297
}
298298
}
299299

300+
fn sum(&self, py: Python) -> PyResult<Self> {
301+
let value = self.value.call_method0(py, "sum")?;
302+
Ok(Self::new(value, self.unit))
303+
}
304+
300305
#[getter]
301306
fn unit(&self) -> [i8; 7] {
302307
self.unit.0

0 commit comments

Comments
 (0)