Trait thousands::Separable[][src]

pub trait Separable {
    fn separate_by_policy(&self, policy: SeparatorPolicy) -> String;

    fn separate_with_commas(&self) -> String { ... }
fn separate_with_spaces(&self) -> String { ... }
fn separate_with_dots(&self) -> String { ... } }

Provides methods for formatting numbers with separators between the digits.

Required Methods

Provided Methods

Inserts a comma every three digits from the right.

This is equivalent to self.separate_by_policy(policies::COMMA_SEPARATOR).

Examples

assert_eq!( 12345.separate_with_commas(), "12,345" );

Inserts a space every three digits from the right.

This is equivalent to self.separate_by_policy(policies::SPACE_SEPARATOR).

Examples

assert_eq!( 12345.separate_with_spaces(), "12 345" );

Inserts a period every three digits from the right.

This is equivalent to self.separate_by_policy(policies::DOT_SEPARATOR).

Examples

assert_eq!( 12345.separate_with_dots(), "12.345" );

Implementors