Hi! My name is Raed, and I do computer stuff โจ
You can find my ๐ website, and my ๐ LinkedIn.
Dinero is a Rust port of Dinero.js (unstable)
Home Page: https://crates.io/crates/dinero
License: MIT License
Hi! My name is Raed, and I do computer stuff โจ
You can find my ๐ website, and my ๐ LinkedIn.
What would be the best type to use?
Should we use a BigInt
sort of library instead?
This would be more useful than the docs.rs generated documentation.
Release new versions using Github Actions.
List of things to do before v1 release:
core/src/lib.rs
to make it easier to maintainExplore the idea of transforming Currency
to a trait.
Today the Dinero struct looks like this:
#[derive(Debug, Clone, Copy, Eq)]
pub struct Dinero {
pub amount: i128,
pub currency: Currency, // <--
pub scale: u32,
}
When doing operations on Dinero we often check if they have the same currency at run-time.
Example:
let a = Dinero::new(1, EUR, None);
let b = Dinero::new(2, USD, None);
let z = add(x,y); // <-- This will return an `UnequalCurrencyError`
Using Bounds this can be done at compile time.
pub trait Currency {
const CODE: CountryCode;
const BASE: u32;
const EXPONENT: u32;
}
Then maybe the Dinero struct can look something like this?
#[derive(Debug, Clone, Copy)]
pub struct Dinero<Currency> { // <-- Not sure how to reference the currency here?
pub amount: i128,
pub scale: u32,
}
// A constructor would look like this?
impl Dinero<dyn Currency> {
pub fn new(amount: i128, scale: Option<u32>) -> Dinero<dyn Currency> {
Dinero {
scale: scale.unwrap_or_else(|| self::Currency::EXPONENT.to_owned()),
amount,
}
}
}
let d = Dinero::<USD>::new(42, Some(2));
I'm still not sure how to make this work synthetically. So any help is more than welcome!
Implement the function convert
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.