Skip to content

Commit

Permalink
docs: quantity-safety mentioned in the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Jan 15, 2025
1 parent c4d1049 commit c237c02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c237c02

Please sign in to comment.