graphflo 0.1.0

The graphflo plugin for libflo.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use error::*;
use std::any::Any;
use std::sync::RwLockReadGuard;
use util::Environment;

pub fn cast_this<'a>(this: &'a RwLockReadGuard<Option<Box<Any + Send + Sync>>>) -> Result<&'a Environment> {
    if let Some(some) = this.as_ref() {
        if let Some(some) = Any::downcast_ref(some.as_ref()) {
            Ok(some)
        } else {
            Err(ErrorKind::EnvironmentIsIncorrectType.into())
        }
    } else {
        Err(ErrorKind::EnvironmentNeverSet.into())
    }
}