docs: quantity-safety mentioned in the docs

This commit is contained in:
Mateusz Pusz
2025-01-15 14:03:18 +01:00
parent c4d1049a13
commit c237c02f69
2 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,9 @@ hide:
provides compile-time dimensional analysis and unit/quantity manipulation. Its key strengths
include safety, performance, and developer experience.
It is the first library on the market that, besides being **unit-safe** and **dimension-safe**,
is also **quantity-safe**.
The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units) with a permissive
[MIT license](https://github.com/mpusz/units/blob/master/LICENSE.md).

View File

@ -165,10 +165,9 @@ error: no viable conversion from returned value of type
## Typed quantities
Simple mode is all about and just about units. In case we care about a specific quantity type,
**typed quantities** should be preferred. With this mode, for example, we can specify if we
deal with _width_, _height_, or _radius_ and ensure we will not assign one to another by
accident.
Simple mode is all about and just about units. **Typed quantities** should be preferred if we also
want to be **quantity-safe**. This, for example, allows us to specify if we deal with _width_,
_height_, or _radius_ and ensure we will not assign one to another by accident.
The previous example can be re-typed using typed quantities in the following way:
@ -249,7 +248,7 @@ error: no viable conversion from returned value of type
As we can see above, the compilation error is longer but still relatively easy to understand.
### Additional type safety with typed quantities
### Quantity-safety with typed quantities
Based on the previous example, it might seem that typed quantities are not that useful,
more to type and provide harder-to-understand error messages. It might be true in some cases,