[][src]Macro fin_model::assert_is_valid

macro_rules! assert_is_valid {
    ($symbol:expr) => { ... };
}

Short-cut to test whether a Symbol is valid, and if not to return a RequestResult containing the error RequestError::BadSymbolError.

This macro requires that is_valid and request::RequestError are in scope where the assertion is made.

Example

The following example shoes the use of the macro, and specifically the necessary imports.

use fin_model::request::{RequestError, RequestResult};
use fin_model::symbol::is_valid;

fn latest_price_only(&self, for_symbol: Symbol) -> RequestResult<f32> {
    assert_is_valid!(for_symbol);
    Ok(0.0)
}