Giter Site home page Giter Site logo

lotus's Introduction

Lotus

Basic currency and number formatting library.

Installation

  1. Add the following lines to your Cargo.toml
[dependencies]
Lotus = "0.1.1" 
  1. Use it in your crate:
extern crate Lotus;
use Lotus::*;

Usage

Here are some examples which illustrate the library functionality. Please read the documentation as well.

extern crate Lotus;
use Lotus::*;

// Builder format (recommended)
let rupee = LotusBuilder::default()
    .symbol("Rs.")
    .precision(1)
    .format_positive("{symbol} {value}")
    .format_negative("{symbol} ({value})")
    .format_zero("{symbol} 0.00")
    .decimal_str(".")
    .thousand_str(" ")
    .build()
    .unwrap();
assert_eq!("Rs. 2 000 000.0", rupee.format(2_000_000));
assert_eq!("Rs. (2 000.0)", rupee.format(-2000));
assert_eq!("Rs. 0.00", rupee.format(0));

// Using Lotus::new()
let dollar = Lotus::new("$", 3); // Lotus::new(symbol, precision)
assert_eq!("$ 50,000.035", dollar.format(50_000.035));

// Using lotus! macro
let f = lotus!(150, "$");     // lotus!(number, symbol)
assert_eq!("$ 150.00", f);

let g = lotus!(2_000_000);    // lotus!(number)
assert_eq!("2,000,000.00", g);

Other Programming Languages

lotus's People

Contributors

nerdypepper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.