1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # XRUnits
//! XRUnits is a unit library
//! # **My english is NOT very good !!**
//! ## Motivation
//! We usually use some real-world unit.
//! If we need to develop a program to deal with these units,
//! like creating a downloader which need to calculate the
//! data transfer speed or set the frequency of MCU,we need
//! do lots of duplicate works to convert these unit, so I want
//! to develop a unit library with STRONG TYPE and Easily using
//! to deal with these situations.
//! ## Details
//! To avoid duplicate code,I use lots of macro to automatically
//! generate code.
//! ## Examples
//! To create 2Kg
//! ```
//! # use xrunits::mass::BuildKilogram;
//! let mass = 2.kg();
//! ```
//! Convert it to ton and gram
//! ```
//! # use xrunits::mass::{Ton, BuildKilogram, Gram};
//! # use xrunits::CastTo;
//! let mass : Ton = 2.kg().cast_to();
//! let mass : Gram = mass.cast_to();
//! ```
//! Print to screen
//! ```
//! # use xrunits::time::BuildSecond;
//! println!("time:{}",3.sec()); //time:3s
//! ```
//! Calculate the Frequency from Period
//! ```
//! # use xrunits::time::{BuildMicrosecond, IntoFrequency};
//! # use xrunits::frequency::Megahertz;
//! let us = 1.us();
//! let mhz : Megahertz = us.into_frequency();
//! ```
/// the length Unit
/// the Time Unit
/// the Data Unit
/// the Frequency Unit
/// the Mass Unit
/// the Angle Unit
/// Core Trait that represent a Unit
/// # Cast a unit to another unit