# Trait num_traits::cast::NumCast [−] [src]

    pub trait NumCast: Sized + ToPrimitive {
        fn from<T: ToPrimitive>(n: T) -> Option<Self>;
    }

An interface for casting between machine scalars.

## Required Methods

### `fn from<T: ToPrimitive>(n: T) -> Option<Self>`

Creates a number from another value that can be converted into a primitive via the `ToPrimitive` trait.

## Implementors

- `impl NumCast for u8`
- `impl NumCast for u16`
- `impl NumCast for u32`
- `impl NumCast for u64`
- `impl NumCast for usize`
- `impl NumCast for i8`
- `impl NumCast for i16`
- `impl NumCast for i32`
- `impl NumCast for i64`
- `impl NumCast for isize`
- `impl NumCast for f32`
- `impl NumCast for f64`
- `impl<T: NumCast> NumCast for Wrapping<T>`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)