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
BYN
BZD
CAD
CDF
CHE
CHF
CHW
CLF
CLP
CNY
COP
COU
CRC
CUC
CUP
CVE
CZK
DJF
DKK
DOP
DZD
EGP
ERN
ETB
EUR
FJD
FKP
GBP
GEL
GHS
GIP
GMD
GNF
GTQ
GYD
HKD
HNL
HRK
HTG
HUF
IDR
ILS
INR
IQD
IRR
ISK
JMD
JOD
JPY
KES
KGS
KHR
KMF
KPW
KRW
KWD
KYD
KZT
LAK
LBP
LKR
LRD
LSL
LYD
MAD
MDL
MGA
MKD
MMK
MNT
MOP
MRU
MUR
MVR
MWK
MXN
MXV
MYR
MZN
NAD
NGN
NIO
NOK
NPR
NZD
OMR
PAB
PEN
PGK
PHP
PKR
PLN
PYG
QAR
RON
RSD
RUB
RWF
SAR
SBD
SCR
SDG
SEK
SGD
SHP
SLE
SLL
SOS
SRD
SSP
STN
SVC
SYP
SZL
THB
TJS
TMT
TND
TOP
TRY
TTD
TWD
TZS
UAH
UGX
USD
USN
UYI
UYU
UYW
UZS
VED
VES
VND
VUV
WST
XAF
XAG
XAU
XBA
XBB
XBC
XBD
XCD
XDR
XOF
XPD
XPF
XPT
XSU
XTS
XUA
XXX
YER
ZAR
ZMW
ZWL
Implementations§
source§impl Currency
impl Currency
sourcepub fn numeric(self) -> u16
pub fn numeric(self) -> u16
Returns the numeric code of the currency
This method will return the ISO 4217 numeric code of the currency
Example
use iso_currency::Currency;
assert_eq!(Currency::EUR.numeric(), 978);
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of the currency in English
This method will return the English name of the currency
Example
use iso_currency::Currency;
assert_eq!(Currency::EUR.name(), "Euro");
sourcepub fn code(self) -> &'static str
pub fn code(self) -> &'static str
Returns the ISO 4217 code
Example
use iso_currency::Currency;
assert_eq!(Currency::EUR.code(), "EUR");
sourcepub fn used_by(self) -> Vec<Country>
pub fn used_by(self) -> Vec<Country>
Returns a list of locations which use the currency
This method will return a list of locations which use the currency. The use is non-exclusive, so it might mean that the location is using other currencies as well. The list of locations is sorted.
Example
use iso_currency::{Currency, Country};
assert_eq!(
Currency::CHF.used_by(),
vec![Country::LI, Country::CH]
);
sourcepub fn symbol(self) -> CurrencySymbol
pub fn symbol(self) -> CurrencySymbol
Returns the currency’s symbol
This method will return the symbol commonly used to represent the currency. In case there is no symbol associated the international currency symbol will be returned.
Example
use iso_currency::Currency;
assert_eq!(format!("{}", Currency::EUR.symbol()), "€");
assert_eq!(format!("{}", Currency::XXX.symbol()), "¤");
sourcepub fn from_code(code: &str) -> Option<Currency>
pub fn from_code(code: &str) -> Option<Currency>
Create a currency instance from a ISO 4217 character code
Example
use iso_currency::Currency;
assert_eq!(Currency::from_code("EUR"), Some(Currency::EUR));
sourcepub fn from_numeric(numeric_code: u16) -> Option<Currency>
pub fn from_numeric(numeric_code: u16) -> Option<Currency>
Create a currency instance from a ISO 4217 numeric code
Example
use iso_currency::Currency;
assert_eq!(Currency::from_numeric(978), Some(Currency::EUR));
sourcepub fn exponent(self) -> Option<u16>
pub fn exponent(self) -> Option<u16>
Returns the exponent of a currency (number of decimal places) For example, 1.00 Euro a 2 subunits so this will return Some(2) for EUR.
This returns an optional value because some currencies don’t have a subunit.
Example
use iso_currency::Currency;
assert_eq!(Currency::EUR.exponent(), Some(2));
assert_eq!(Currency::JPY.exponent(), Some(0));
sourcepub fn subunit_fraction(self) -> Option<u16>
pub fn subunit_fraction(self) -> Option<u16>
Returns how many of the subunits equal the main unit of the currency For example there are a 100 cents in 1 Euro so this will return Some(100) for EUR.
This returns an optional value because some currencies don’t have a subunit.
Example
use iso_currency::Currency;
assert_eq!(Currency::EUR.subunit_fraction(), Some(100));
Trait Implementations§
source§impl<'de> Deserialize<'de> for Currency
impl<'de> Deserialize<'de> for Currency
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl IntoEnumIterator for Currency
impl IntoEnumIterator for Currency
type Iterator = CurrencyIter
fn iter() -> CurrencyIter ⓘ
source§impl Ord for Currency
impl Ord for Currency
source§impl PartialEq<Currency> for Currency
impl PartialEq<Currency> for Currency
source§impl PartialOrd<Currency> for Currency
impl PartialOrd<Currency> for Currency
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more