Skip to content

Commit 94b1edd

Browse files
authored
Release v0.6.1 (#54)
1 parent 968e92f commit 94b1edd

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

CHANGELOG.md

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

77
## [Unreleased]
88

9+
## [0.6.1] - 2023-08-06
10+
### Added
11+
- Added new functions `Quantity::from_raw_parts` and `Quantity::into_raw_parts` for SI quantities. [#54](https://github.com/itt-ustutt/quantity/pull/54)
12+
913
## [0.6.0] - 2023-01-20
1014
### Added
1115
- Added the new SI unit prefixes `QUECTO`, `RONTO`, `RONNA`, and `QUETTA`. [#49](https://github.com/itt-ustutt/quantity/pull/49)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "quantity"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
authors = ["Philipp Rehner <[email protected]>",
55
"Gernot Bauer <[email protected]>"]
66
edition = "2018"

si-units/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "si-units"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
authors = ["Philipp Rehner <[email protected]>",
55
"Gernot Bauer <[email protected]>"]
66
edition = "2018"

src/si.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ pub type SIArray4 = SIArray<Ix4>;
105105
pub type SIArray5 = SIArray<Ix5>;
106106
pub type SIArray6 = SIArray<Ix6>;
107107

108+
impl<T> Quantity<T, SIUnit> {
109+
/// Split an SI quantity into its value and unit vector.
110+
pub fn into_raw_parts(self) -> (T, [i8; 7]) {
111+
(self.value, self.unit.0)
112+
}
113+
114+
/// Create an SI quantity from its value and unit vector.
115+
pub fn from_raw_parts(value: T, unit: [i8; 7]) -> Self {
116+
Quantity {
117+
value,
118+
unit: SIUnit(unit),
119+
}
120+
}
121+
}
122+
108123
impl Unit for SIUnit {
109124
const DIMENSIONLESS: Self = SIUnit([0; 7]);
110125

0 commit comments

Comments
 (0)