pub enum Currency {
Show 181 variants AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, 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,
}

Variants§

§

AED

§

AFN

§

ALL

§

AMD

§

ANG

§

AOA

§

ARS

§

AUD

§

AWG

§

AZN

§

BAM

§

BBD

§

BDT

§

BGN

§

BHD

§

BIF

§

BMD

§

BND

§

BOB

§

BOV

§

BRL

§

BSD

§

BTN

§

BWP

§

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

source

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);
source

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");
source

pub fn code(self) -> &'static str

Returns the ISO 4217 code

Example
use iso_currency::Currency;

assert_eq!(Currency::EUR.code(), "EUR");
source

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]
);
source

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()), "¤");
source

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));
source

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));
source

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));
source

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 Clone for Currency

source§

fn clone(&self) -> Currency

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Currency

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Currency

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Currency

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Currency

§

type Err = ParseCurrencyError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Currency

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IntoEnumIterator for Currency

source§

impl Ord for Currency

source§

fn cmp(&self, other: &Currency) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Currency> for Currency

source§

fn eq(&self, other: &Currency) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Currency> for Currency

source§

fn partial_cmp(&self, other: &Currency) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Currency

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Currency

source§

impl Eq for Currency

source§

impl StructuralEq for Currency

source§

impl StructuralPartialEq for Currency

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,