Expand description
Derive macro implementation used by qtty-core.
qtty-derive is an implementation detail of this workspace. By default the
Unit derive expands in terms of crate::Unit and crate::Quantity, which
matches qtty-core. Downstream crates can target the public qtty facade by
adding crate = qtty to the helper attribute.
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- when targeting the defining crate itself, formatting impls for
crate::Quantity<MyUnit, S>(Display,LowerExp,UpperExp)
§Attributes
The derive reads a required #[unit(...)] attribute:
symbol = "m": displayed unit symboldimension = SomeDim: dimension marker typeratio = 1000.0: conversion ratio to the canonical unit of the dimensioncrate = qtty: optional crate path when deriving from a downstream crate
Derive Macros§
- Unit
- Derive
crate::Unitand aDisplayimpl forcrate::Quantity<ThisUnit>.