Crate qtty_derive

Crate qtty_derive 

Source
Expand description

Derive macro implementation used by qtty-core.

qtty-derive is an implementation detail of this workspace. The Unit derive expands in terms of crate::Unit and crate::Quantity, so it is intended to be used by qtty-core (or by crates that expose an identical crate-root API).

Most users should depend on qtty instead and use the predefined units.

§Generated impls

For a unit marker type MyUnit, the derive implements:

  • crate::Unit for MyUnit
  • core::fmt::Display for crate::Quantity<MyUnit> (formats as <value> <symbol>)

§Attributes

The derive reads a required #[unit(...)] attribute:

  • symbol = "m": displayed unit symbol
  • dimension = SomeDim: dimension marker type
  • ratio = 1000.0: conversion ratio to the canonical unit of the dimension

Derive Macros§

Unit
Derive crate::Unit and a Display impl for crate::Quantity<ThisUnit>.