rust_dynamic 0.49.0

Support for dynamically-typed values in run-time
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::value::Value;
use crate::types::*;

impl Value {
    pub fn cast_matrix(&self) -> Result<Vec<Vec<Value>>, Box<dyn std::error::Error>> {
        if self.dt != MATRIX {
            return Err(format!("This is not a MATRIX value but {}", &self.dt).into());
        }
        match &self.data {
            Val::Matrix(m_val) => {
                return Result::Ok(m_val.clone());
            }
            _ => return Err("This Dynamic type is not matrix".into()),
        }
    }
}