Crates.io | convers |
lib.rs | convers |
version | 0.2.1 |
source | src |
created_at | 2024-11-01 08:55:21.325651 |
updated_at | 2024-11-08 18:18:58.378558 |
description | Cool convert library that converts almost everything(not yet).Units,Languages,Calculations,etc. |
homepage | |
repository | https://github.com/veaquer/convers |
max_upload_size | |
id | 1431566 |
size | 31,576 |
convers
- is a cool library for converting data from one format to another.
The idea is to convert everything from one query, like from one language, unit, etc., to another.
There are functions that allow you to do something like that.
magic_convert
function:use convers::convert::magic_convert;
#[tokio::main]
async fn main() {
let query = "1m to cm".to_string();
let result = magic_convert(&query).await.unwrap(); // Is String - "100 Centimeters"
let translate_result = magic_convert(&String::from("en:de how are u?")).await.unwrap(); // Is String - "wie geht es dir?" or something like that
let calculated = magic_convert(&String::from("15/3")).await.unwrap(); // Is String - "5" or "5.0"
}
use convers::utils::units::{Measurement, Unit};
let a = Measurement::new(50.0, Unit::Meter);
let b = Measurement::new(1.0, Unit::Kilometer);
let c = a + b; // anyhow::Result<Measurement>. If unwrap it equals 1.050 Kilometer