Skip to main content

Count

Trait Count 

Source
pub trait Count {
    // Required method
    fn to_count(&self) -> i64;
}
Expand description

A number Translation::count accepts: every integer type, and references to them.

References are accepted because askama passes template fields by reference. Values outside the i64 range count as i64::MAX.

§Examples

use ocre::i18n::Count;
assert_eq!(3_usize.to_count(), 3);
assert_eq!((&-2_i32).to_count(), -2);
assert_eq!(u64::MAX.to_count(), i64::MAX);

Required Methods§

Source

fn to_count(&self) -> i64

Returns the number as i64, or i64::MAX when it does not fit.

§Examples
use ocre::i18n::Count;
assert_eq!(7_u8.to_count(), 7);

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Count for i8

Source§

fn to_count(&self) -> i64

Source§

impl Count for i16

Source§

fn to_count(&self) -> i64

Source§

impl Count for i32

Source§

fn to_count(&self) -> i64

Source§

impl Count for i64

Source§

fn to_count(&self) -> i64

Source§

impl Count for i128

Source§

fn to_count(&self) -> i64

Source§

impl Count for isize

Source§

fn to_count(&self) -> i64

Source§

impl Count for u8

Source§

fn to_count(&self) -> i64

Source§

impl Count for u16

Source§

fn to_count(&self) -> i64

Source§

impl Count for u32

Source§

fn to_count(&self) -> i64

Source§

impl Count for u64

Source§

fn to_count(&self) -> i64

Source§

impl Count for u128

Source§

fn to_count(&self) -> i64

Source§

impl Count for usize

Source§

fn to_count(&self) -> i64

Source§

impl<T: Count + ?Sized> Count for &T

Source§

fn to_count(&self) -> i64

Implementors§