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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//! Temperature conversion functions organized by unit type
/// Celsius conversion functions
/// Fahrenheit conversion functions
/// Kelvin conversion functions
// Legacy function wrappers for backward compatibility
/// Converts Celsius to Fahrenheit (legacy function).
///
/// **Note:** Consider using `celsius::to_fahrenheit()` for better organization.
///
/// Uses the formula: °F = (°C × 9/5) + 32
///
/// # Arguments
///
/// * `celsius` - The temperature in Celsius to convert
///
/// # Returns
///
/// The equivalent temperature in Fahrenheit
///
/// # Examples
///
/// ```
/// use conversions_rs::celsius_to_fahrenheit;
///
/// let fahrenheit = celsius_to_fahrenheit(0.0);
/// assert_eq!(fahrenheit, 32.0);
///
/// let fahrenheit = celsius_to_fahrenheit(100.0);
/// assert_eq!(fahrenheit, 212.0);
/// ```
/// Converts Fahrenheit to Celsius (legacy function).
///
/// **Note:** Consider using `fahrenheit::to_celsius()` for better organization.
///
/// Uses the formula: °C = (°F - 32) × 5/9
///
/// # Arguments
///
/// * `fahrenheit` - The temperature in Fahrenheit to convert
///
/// # Returns
///
/// The equivalent temperature in Celsius
///
/// # Examples
///
/// ```
/// use conversions_rs::fahrenheit_to_celsius;
///
/// let celsius = fahrenheit_to_celsius(32.0);
/// assert_eq!(celsius, 0.0);
///
/// let celsius = fahrenheit_to_celsius(212.0);
/// assert_eq!(celsius, 100.0);
/// ```
/// Converts Celsius to Kelvin (legacy function).
///
/// **Note:** Consider using `celsius::to_kelvin()` for better organization.
///
/// Uses the formula: K = °C + 273.15
///
/// # Arguments
///
/// * `celsius` - The temperature in Celsius to convert
///
/// # Returns
///
/// The equivalent temperature in Kelvin
///
/// # Examples
///
/// ```
/// use conversions_rs::celsius_to_kelvin;
///
/// let kelvin = celsius_to_kelvin(0.0);
/// assert_eq!(kelvin, 273.15);
///
/// let kelvin = celsius_to_kelvin(-273.15);
/// assert_eq!(kelvin, 0.0);
/// ```
/// Converts Kelvin to Celsius (legacy function).
///
/// **Note:** Consider using `kelvin::to_celsius()` for better organization.
///
/// Uses the formula: °C = K - 273.15
///
/// # Arguments
///
/// * `kelvin` - The temperature in Kelvin to convert
///
/// # Returns
///
/// The equivalent temperature in Celsius
///
/// # Examples
///
/// ```
/// use conversions_rs::kelvin_to_celsius;
///
/// let celsius = kelvin_to_celsius(273.15);
/// assert_eq!(celsius, 0.0);
///
/// let celsius = kelvin_to_celsius(373.15);
/// assert_eq!(celsius, 100.0);
/// ```
/// Converts Fahrenheit to Kelvin (legacy function).
///
/// **Note:** Consider using `fahrenheit::to_kelvin()` for better organization.
///
/// Converts through Celsius as an intermediate step for accuracy.
///
/// # Arguments
///
/// * `fahrenheit` - The temperature in Fahrenheit to convert
///
/// # Returns
///
/// The equivalent temperature in Kelvin
///
/// # Examples
///
/// ```
/// use conversions_rs::fahrenheit_to_kelvin;
///
/// let kelvin = fahrenheit_to_kelvin(32.0);
/// assert_eq!(kelvin, 273.15);
/// ```
/// Converts Kelvin to Fahrenheit (legacy function).
///
/// **Note:** Consider using `kelvin::to_fahrenheit()` for better organization.
///
/// Converts through Celsius as an intermediate step for accuracy.
///
/// # Arguments
///
/// * `kelvin` - The temperature in Kelvin to convert
///
/// # Returns
///
/// The equivalent temperature in Fahrenheit
///
/// # Examples
///
/// ```
/// use conversions_rs::kelvin_to_fahrenheit;
///
/// let fahrenheit = kelvin_to_fahrenheit(273.15);
/// assert_eq!(fahrenheit, 32.0);
/// ```
/// Converts between any two supported temperature units.
///
/// This function handles conversions between Celsius, Fahrenheit, and Kelvin.
/// All conversions use the standard formulas and maintain high precision.
///
/// # Supported Units
///
/// * **Celsius:** `c`, `celsius`
/// * **Fahrenheit:** `f`, `fahrenheit`
/// * **Kelvin:** `k`, `kelvin`
///
/// Unit names are case-insensitive.
///
/// # Arguments
///
/// * `value` - The temperature value to convert
/// * `from` - The source temperature unit (case-insensitive)
/// * `to` - The target temperature unit (case-insensitive)
///
/// # Returns
/// * `Ok(f64)` - The converted temperature if both units are recognized
/// * `Err(String)` - An error message if either unit is not supported
///
/// # Examples
///
/// ```
/// use conversions_rs::convert_temperature;
///
/// // Convert freezing point of water
/// let result = convert_temperature(0.0, "C", "F").unwrap();
/// assert_eq!(result, 32.0);
///
/// // Convert boiling point of water
/// let result = convert_temperature(212.0, "F", "C").unwrap();
/// assert_eq!(result, 100.0);
///
/// // Convert absolute zero
/// let result = convert_temperature(0.0, "K", "C").unwrap();
/// assert_eq!(result, -273.15);
///
/// // Case-insensitive units work
/// let result = convert_temperature(25.0, "CELSIUS", "fahrenheit").unwrap();
/// assert_eq!(result, 77.0);
///
/// // Error handling for unknown units
/// assert!(convert_temperature(100.0, "invalid", "C").is_err());
/// ```
///
/// # Temperature Scale Information
///
/// * **Celsius (°C):** Water freezes at 0°C, boils at 100°C at standard pressure
/// * **Fahrenheit (°F):** Water freezes at 32°F, boils at 212°F at standard pressure
/// * **Kelvin (K):** Absolute temperature scale, 0K = absolute zero (-273.15°C)