Trait factorial::Factorial[][src]

pub trait Factorial<Target = Self> {
    fn checked_factorial(&self) -> Option<Target>;

    fn factorial(&self) -> Target { ... }
}

Unary operator for computing the factorial of a number

Implements checked and unchecked versions of the formula

Required Methods

Returns self!, i.e. the factorial of self, if it doesn't overflow the type T.

Examples

use factorial::Factorial;
assert_eq!(10u32.checked_factorial(), Some(3628800));

Provided Methods

Returns self!, i.e. the factorial of self.

Examples

use factorial::Factorial;
assert_eq!(10u32.factorial(), 3628800);

Implementors