# Trait ethcore::evm::evm::CostType [−] [src]

    pub trait CostType: Sized + From<usize> + Copy + Mul<Output=Self> + Div<Output=Self> + Add<Output=Self> + Sub<Output=Self> + Shr<usize, Output=Self> + Shl<usize, Output=Self> + Ord + Debug {
        fn as_u256(&self) -> U256;
        fn from_u256(val: U256) -> Result<Self>;
        fn as_usize(&self) -> usize;
        fn overflow_add(self, other: Self) -> (Self, bool);
        fn overflow_mul(self, other: Self) -> (Self, bool);
        fn overflow_mul_shr(self, other: Self, shr: usize) -> (Self, bool);
    }

Cost calculation type. For low-gas usage we calculate costs using usize instead of U256

## Required Methods

### `fn as_u256(&self) -> U256`

Converts this cost into `U256`

### `fn from_u256(val: U256) -> Result<Self>`

Tries to fit `U256` into this `Cost` type

### `fn as_usize(&self) -> usize`

Convert to usize (may panic)

### `fn overflow_add(self, other: Self) -> (Self, bool)`

Add with overflow

### `fn overflow_mul(self, other: Self) -> (Self, bool)`

Multiple with overflow

### `fn overflow_mul_shr(self, other: Self, shr: usize) -> (Self, bool)`

Single-step full multiplication and shift: `(self*other) >> shr` Should not overflow on intermediate steps

## Implementors

- `impl CostType for U256`
- `impl CostType for usize`

# 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`)