Skip to content

Commit

Permalink
Merge pull request #425 from NiklasVousten/conversion-doc
Browse files Browse the repository at this point in the history
Changed documentation of Conversion

Resolves #424.
  • Loading branch information
iliekturtles authored Jul 13, 2023
2 parents 6d34c3e + d5e24b2 commit 787272d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,20 +426,22 @@ pub trait Conversion<V> {
type T: ConversionFactor<V>;

/// Coefficient portion of [conversion factor](https://jcgm.bipm.org/vim/en/1.24.html) for
/// converting the given unit to the base unit for the quantity: `(value * coefficient()) +
/// constant()`. Implementation should return the multiplicative identity (`Self::T::one()`) if
/// no coefficient exists.
/// converting the given unit. To convert to the base unit for the quantity use `(value +
/// constant()) * coefficient()`. To convert from the base unit, `(value / coefficient()) -
/// constant()` is used. Implementation should return the multiplicative identity
/// (`Self::T::one()`) if no coefficient exists.
#[must_use = "method returns a new number and does not mutate the original value"]
#[inline(always)]
fn coefficient() -> Self::T {
<Self::T as crate::num::One>::one()
}

/// Constant portion of [conversion factor](https://jcgm.bipm.org/vim/en/1.24.html) for
/// converting the given unit to the base unit for the quantity: `(value * coefficient()) +
/// constant()`. Implementation should return the additive identity (`Self::T::zero()`) if no
/// constant exists. See [ConstantOp](enum.ConstantOp.html) documentation for details about
/// parameter use to ensure the method optimizes correctly.
/// converting the given unit. To convert to the base unit for the quantity use `(value +
/// constant()) * coefficient()`. To convert from the base unit, `(value / coefficient()) -
/// constant()` is used. Implementation should return the additive identity (`Self::T::zero()`)
/// if no constant exists. See [ConstantOp](enum.ConstantOp.html) documentation for details
/// about parameter use to ensure the method optimizes correctly.
#[must_use = "method returns a new number and does not mutate the original value"]
#[inline(always)]
#[allow(unused_variables)]
Expand Down

0 comments on commit 787272d

Please sign in to comment.